Memory and disk cache for functions
Project description
Not again!
Memoize any function with this lightweight decorator, even across runs. It stores results in memory and disk.
The decorator makes use of the Pickle module to store (and retrieve) function results in a local cache folder.
Memoization is sensible to the function input arguments and source code, if any of these change the function gets executed and its output cached.
Get it
pip install notagain
Use it
from notagain import memoize
@memoize()
def expensive_function(arg, kwarg=None):
# i.e. some boring query
return arg
Control it
You can change the pickles path. You can deactivate memory and/or disk cache.
@memoize(cache_dir='tmp', memory_cache=True, disk_cache=True)
If you would like to disable this library info messages.
logging.getLogger('notagain').setLevel('WARNING')
About the name
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
notagain-0.3.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for notagain-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3537d33c2260e75fa9014ddf40930ca6c23bace7070ded47786de43503d6c911 |
|
MD5 | 4a17a03a93d6bb16018972a8e690e976 |
|
BLAKE2b-256 | a6bb467f2834914af555a6f670d4ad6c4b313f73cebcb72dc0575c9602d165a5 |