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 2 and 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.
Citing
------
Please cite this package as:
[Tor19]
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](https://github.com/OpenDreamKit/OpenDreamKit/blob/master/WP6/D6.9/report-final.pdf).
<table class="none">
<tr>
<td>
<img src="http://opendreamkit.org/public/logos/Flag_of_Europe.svg" width="128">
</td>
<td>
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.
</td>
</tr>
</table>
=========
[](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 2 and 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.
Citing
------
Please cite this package as:
[Tor19]
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](https://github.com/OpenDreamKit/OpenDreamKit/blob/master/WP6/D6.9/report-final.pdf).
<table class="none">
<tr>
<td>
<img src="http://opendreamkit.org/public/logos/Flag_of_Europe.svg" width="128">
</td>
<td>
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.
</td>
</tr>
</table>
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.8.tar.gz
(17.0 kB
view details)
File details
Details for the file pypersist-0.8.tar.gz.
File metadata
- Download URL: pypersist-0.8.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
669b293536dbfd1f4117ede1d1d96cfe3cdddedcd5f4b0541224307f3e9665a3
|
|
| MD5 |
9bfe942f231d1ede81f0f025c3fffddf
|
|
| BLAKE2b-256 |
db197c6293b5bfcf34bfaa972642b9f017902ca885ee5c93e0fd47bc922677c8
|