Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
joblib caching for expensive functions
import joblib
import os
cachedir = 'cache'
if not os.path.isdir(cachedir): os.mkdir(cachedir)
mem = joblib.Memory(cachedir=cachedir, verbose=True)
@mem.cache
def my_long_function(i):
return i + i
# first call is done normally
print my_long_function(1)
# second call is loaded from cache directory
print my_long_function(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.