Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept function to create hashable keys from args #5

Open
brmscheiner opened this issue Jul 6, 2018 · 4 comments
Open

Accept function to create hashable keys from args #5

brmscheiner opened this issue Jul 6, 2018 · 4 comments

Comments

@brmscheiner
Copy link
Owner

Based on discussion with @JoranDox in #3

Allow users to provide a function that maps arguments to some sort of hashable key. This will enable people to use the Memorize decorator with functions that accept non-hashable arguments. Target API:

def getHash(arg1, arg2):
    return str([arg1, arg2])

@Memorize(getHash)
def myFunction(arg1, arg2):
    ....
@brmscheiner
Copy link
Owner Author

One caveat: I think we will need to save a hash of the function to the cache as well, so that when myFunction is called again we can verify that the getHash function has not changed.

@brmscheiner
Copy link
Owner Author

@cjbassi do you have an opinion about this?

@cjbassi
Copy link
Contributor

cjbassi commented Jul 14, 2018

I think the concept looks good. So check getHash when Memorize is initialized? And recreate the cache file if it has changed?

@brmscheiner
Copy link
Owner Author

yes, that's the idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants