I have a function with two parameters:
def foo(x,y):
# some complicated math
return result
and I define partials using the functools
library:
f1 = partial(foo,1)
f2 = partial(foo,2)
Now I would like to use the joblib.Memory
library to cache the results in disk to avoid re-computation.
from joblib import Memory
mem = Memory(cachedir = '/tmp')
f1c = mem.cache(f1)
f2c = mem.cache(f2)
res1 = f1c(10)
res2 = f1c(10)
When I run the code, I get the warning:
JobLibCollisionWarning: Cannot detect name collisions
for function 'unknown
Also the results are not cached. Is there a way to use partial objects with Memory library?