Skip to main content

Persistent memoisation framework for Python

Project description

pypersist

Build Status codecov Documentation Status PyPI version Binder

pypersist is a persistent memoisation framework for Python 3. Persistent memoisation is the practice of storing the output of a function permanently to a disk or a server so that the result can be looked up automatically in the future, avoiding any known results being recomputed unnecessarily.

Installation

pypersist is available from PyPI, and the latest release can be installed using, for example:

pip3 install --user pypersist

Alternatively, the latest development version can be installed using Github:

git clone https://github.com/mtorpey/pypersist.git
pip3 install --user ./pypersist

Examples

To use, import the persist class from the pypersist package:

from pypersist import persist

and use it as a decorator when writing a function:

@persist
def double(x):
    return x * 2

print(double(3))
print(double(6.5))

This will store the outputs of the double function in a directory called persist/double/, in a machine-readable format.

One can specify various arguments to persist. For example:

@persist(key=lambda x,y: (x,y),
         hash=lambda k: '%s_to_the_power_of_%s' % k,
         pickle=str,
         unpickle=int)
def power(x, y):
    return x ** y

print(power(2,4))
print(power(10,5))

will store the outputs of power in human-readable files with descriptive filenames.

Many more options are available. See the persist class documentation for a full description, or launch the included notebook on Binder for more examples.

See this HackMD and the Issue tracker for current plans.

Citing

Please cite this package as:

[Tor20] M. Torpey, pypersist, Python memoisation framework, Version X.Y (20XX), https://github.com/mtorpey/pypersist.

Acknowledgements

pypersist was created as part of the OpenDreamKit project: https://opendreamkit.org/

This part of the project is summarised in this report.

This infrastructure is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreement No 676541.

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

pypersist-1.1.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

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

pypersist-1.1-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file pypersist-1.1.tar.gz.

File metadata

  • Download URL: pypersist-1.1.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for pypersist-1.1.tar.gz
Algorithm Hash digest
SHA256 0b52bcd67de4b9e291cb36d3eac6e89bd0db00f0c7be2ab9d1ed90dbe7d22591
MD5 7b0090b2e958f331790266f7d1cd7f5e
BLAKE2b-256 2095fedfaedae15eecfd707fce8cba8a8bdcc013d74f7948fc9f8a34b2226360

See more details on using hashes here.

File details

Details for the file pypersist-1.1-py3-none-any.whl.

File metadata

  • Download URL: pypersist-1.1-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.2

File hashes

Hashes for pypersist-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 00296ac75c759033624cf301da8ecacf83254ee2c7e003c213297831c1b8c858
MD5 94d0d909a4f6573553e09398e2b786da
BLAKE2b-256 6c94532c696263c5a32740a320ac6ba3c131331a7ddf7db6813ddc0b475a1c79

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