from joblib import Memory memory = Memory(cachedir='/tmp/example/') @memory.cache def f(x): return x