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)


CPU times: user 4 ms, sys: 0 ns, total: 4 ms
Wall time: 3.78 ms
Out[8]:
1

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)

resu


In [ ]:
%time myfunc(1)