Skip to main content

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

https://www.youtube.com/watch?v=SOBNO4gl_yM

Project details


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)

Uploaded Source

Built Distribution

notagain-0.3-py2.py3-none-any.whl (3.3 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page