Skip to main content

Cache any python object to file using improved pickling .

Project description

https://badge.fury.io/py/anycache.svg https://travis-ci.org/c0fec0de/anycache.svg?branch=master https://coveralls.io/repos/github/c0fec0de/anycache/badge.svg https://readthedocs.org/projects/anycache/badge/?version=2.0.7 https://codeclimate.com/github/c0fec0de/anycache.png https://img.shields.io/pypi/pyversions/anycache.svg https://landscape.io/github/c0fec0de/anycache/master/landscape.svg?style=flat https://img.shields.io/badge/code%20style-pep8-brightgreen.svg https://img.shields.io/badge/code%20style-pep257-brightgreen.svg

Cache any python object to file using improved pickling

Documentation

The Documentation is hosted on http://anycache.readthedocs.io/en/2.0.7/

Getting started

To cache the result of a function, use the global unlimited anycache:

>>> 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 build-in pickle.

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

>>> 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.

Installation

To install the anycache module run:

pip install anycache

If you do not have write-permissions to the python installation, try:

pip install anycache --user

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

anycache-2.0.7.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anycache-2.0.7-py2.py3-none-any.whl (10.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file anycache-2.0.7.tar.gz.

File metadata

  • Download URL: anycache-2.0.7.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for anycache-2.0.7.tar.gz
Algorithm Hash digest
SHA256 b4e372dece09eba8733e8e08873da8d7793bfee8fc9457c657bb054d3bfa25ff
MD5 8f1be40ccf11c1cf00443127753f91b8
BLAKE2b-256 f5fd997bcb31ca2351bc6ded3dbb301590c32670d9bca832e5415c1667c20d8d

See more details on using hashes here.

File details

Details for the file anycache-2.0.7-py2.py3-none-any.whl.

File metadata

  • Download URL: anycache-2.0.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for anycache-2.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 606c4f3f938f32634261458357a0ccb2a6aa30521aacb1fd7d8c7cfefedefea3
MD5 5400949ae807cff6fea28e2fb4fd7436
BLAKE2b-256 429417de24bff0b10c5e40e029f9dfbf34f7c5fd381d1cda3bc2c736b162b772

See more details on using hashes here.

Supported by

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