Closed brezniczky closed 5 years ago
The biggest issue with on disk caching is this or that I don't know what the suggested prevention of this from happening is:
from diskcache import Cache
cache = Cache()
@cache.memoize()
def memoized():
return 5
x1 = memoized()
@cache.memoize()
def memoized():
return 10
x2 = memoized()
assert x1 != x2
19
20
---> 21 assert x1 != x2
22
23
AssertionError:
Another problem to foresee is largely depicted below - not sure if I'm just generally sloppy at defining decorators, but could be, anyway, my decorators typically don't return functions with unique names, therefore ... you know.
from diskcache import Cache
cache = Cache()
def primo_decorate(f):
def wrapped(*args, **kwargs):
return f(*args, **kwargs)
return wrapped
@cache.memoize()
@primo_decorate
def memoized3(x):
return x ** 2
z1 = memoized3(5)
@cache.memoize()
@primo_decorate
def memoized3_2(x):
return x ** 2 + 1
z2 = memoized3_2(5)
assert(z1 != z2)
The assertion fails here too.
Of course, these scenarios will potentially frequently recur if I am refining analytics from the REPL.
Safe to say for now joblib's caching did the job.
So that the edit/verify/push loop gets shortcut by about a lot esp. in refactoring situations.