Skip to main content

Quick and dirty caching function results on disk using pickle

Project description


The name stands for pickle cache, and it is a quick and dirty way of caching function results on disk using pickle.

This can be helpful for example in some machine learning tasks, where you have to preprocess the data with many time-consuming steps, and you want to not recompute things every time you run your program.


from pklcache import cache

def foo(args):
    # time consuming operations here...
    return result

If you run the program

result = foo()  #foo executed

And if you run it again

result = foo()  #foo not executed, load result from disk

The first time foo is called its result is saved on disk on foo_cache.pkl. If then the function is called another time or the program is run again, foo is not executed, instead its return value is loaded from disk and returned.


@cache(fpath, enabled=True)

  • fpath: is the cache file path
  • enabled: if False the store/load is disabled and the function is executed like if it wasn't decorated. Useful during development and debugging.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pklcache, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pklcache-0.1-py3-none-any.whl (3.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size pklcache-0.1.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page