Skip to content

Instantly share code, notes, and snippets.

@ipashchenko
Forked from JohannesBuchner/caching.py
Last active August 29, 2015 14:23
Show Gist options
  • Save ipashchenko/e34044e9d6c31b1751bf to your computer and use it in GitHub Desktop.
Save ipashchenko/e34044e9d6c31b1751bf to your computer and use it in GitHub Desktop.
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