Skip to content

c0fec0de/anycache

Repository files navigation

PyPI Version Python Build Documentation Coverage Status python-versions

Cache any python object to file using improved pickling

Installation

Installing it is pretty easy:

pip install anycache

Getting Started

>>> from anycache import anycache
>>> @anycache()
... def myfunc(posarg, kwarg=3):
...     print("  Calcing %r + %r = %r" % (posarg, kwarg, posarg + kwarg))
...     return posarg + kwarg
>>> myfunc(8, 5)
  Calcing 8 + 5 = 13
13
>>> myfunc(8, 5)
13

anycache caches nearly any python object. Also lambda statements. It uses dill as backend. An improved version of pythons built-in pickle.

To preserve the result between multiple python runs, set a persistent cache directory.

>>> from anycache import anycache
>>> @anycache(cachedir='/tmp/anycache.my')
... def myfunc(posarg, kwarg=3):
...     return posarg + kwarg

The AnyCache object serves additional functions for cache clearing and size handling.

About

Cache any python object to file using improved pickling

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages