Accept function to create hashable keys from args
brmscheiner opened this issue · 4 comments
brmscheiner commented
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 commented
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 commented
@cjbassi do you have an opinion about this?
cjbassi commented
I think the concept looks good. So check getHash
when Memorize
is initialized? And recreate the cache file if it has changed?
brmscheiner commented
yes, that's the idea