import time
from joblib import Memory
memory = Memory(location="/home/felipe/sandbox/",verbose=0)
@memory.cache
def myfuncdsk(x):
time.sleep(2)
return x
%time myfuncdsk(1)
CPU times: user 4 ms, sys: 0 ns, total: 4 ms Wall time: 3.78 ms
1
import functools
@functools.lru_cache(5)
def myfuncmem(x):
time.sleep(2)
return x
%time myfunc(1)
%time myfunc(2)
%time myfunc(3)
%time myfunc(4)
%time myfunc(5)
%time myfunc(6)
%time myfunc(1)