Persistent memoisation framework for Python
Project description
pypersist
=========
[](https://travis-ci.org/mtorpey/pypersist)
[](https://codecov.io/gh/mtorpey/pypersist)
[](https://pypersist.readthedocs.io/en/latest/?badge=latest)
[](https://badge.fury.io/py/pypersist)
[](https://mybinder.org/v2/gh/mtorpey/pypersist/master?filepath=binder/demo.ipynb)
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:
```python
from pypersist import persist
```
and use it as a decorator when writing a function:
```python
@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:
```python
@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](https://mybinder.org/v2/gh/mtorpey/pypersist/master?filepath=binder/demo.ipynb)
for more examples.
See [this HackMD](https://hackmd.io/1M5clex-TYWCuxxgi05k5A) and the Issue
tracker for current plans.
pypersist is a part of the OpenDreamKit project: https://opendreamkit.org/
=========
[](https://travis-ci.org/mtorpey/pypersist)
[](https://codecov.io/gh/mtorpey/pypersist)
[](https://pypersist.readthedocs.io/en/latest/?badge=latest)
[](https://badge.fury.io/py/pypersist)
[](https://mybinder.org/v2/gh/mtorpey/pypersist/master?filepath=binder/demo.ipynb)
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:
```python
from pypersist import persist
```
and use it as a decorator when writing a function:
```python
@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:
```python
@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](https://mybinder.org/v2/gh/mtorpey/pypersist/master?filepath=binder/demo.ipynb)
for more examples.
See [this HackMD](https://hackmd.io/1M5clex-TYWCuxxgi05k5A) and the Issue
tracker for current plans.
pypersist is a part of the OpenDreamKit project: https://opendreamkit.org/
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-0.5.tar.gz
(13.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pypersist-0.5-py3-none-any.whl
(14.4 kB
view details)
File details
Details for the file pypersist-0.5.tar.gz.
File metadata
- Download URL: pypersist-0.5.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff0a9c31b67b11c49724510e12e9e760fe00304f7347b5ebe6200bd68a74a814
|
|
| MD5 |
7716418822fb23d35fcee845a6581782
|
|
| BLAKE2b-256 |
0dca2c6d9175899e087bcf8f9078f24a157570a5cacba80d76d0955e98fa06c3
|
File details
Details for the file pypersist-0.5-py3-none-any.whl.
File metadata
- Download URL: pypersist-0.5-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57fd0b84d8acd005a3801dd113c8cc0dd79bb04b856909f1dfd3ef482e47cb9f
|
|
| MD5 |
00176e21318ad7970bc7dc896909803d
|
|
| BLAKE2b-256 |
966e00249b0d159fc92e1da90b18550a3a85c2b2c4341620f7306847e2f3c544
|