In [1]:
import time
In [2]:
from joblib import Memory
In [6]:
memory = Memory(location="/home/felipe/sandbox/",verbose=0)
In [7]:
@memory.cache
def myfuncdsk(x):
time.sleep(2)
return x
In [8]:
%time myfuncdsk(1)
Out[8]:
In [ ]:
import functools
In [ ]:
@functools.lru_cache(5)
def myfuncmem(x):
time.sleep(2)
return x
In [ ]:
%time myfunc(1)
In [ ]:
%time myfunc(2)
In [ ]:
%time myfunc(3)
In [ ]:
%time myfunc(4)
In [ ]:
%time myfunc(5)
In [ ]:
%time myfunc(6)
In [ ]:
%time myfunc(1)