Last active
December 17, 2015 13:39
-
-
Save JohannesBuchner/5619297 to your computer and use it in GitHub Desktop.
joblib caching for expensive functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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