Memoi
Description
A generic caching mechanism for memoizing function or method calls.
Prerequisites
Python >= 3.10
Installation
python -m pip install memoi
Example
from datetime import datetime as dt
from memoi import cached, TextFileRepo
@cached(TextFileRepo('.'))
def f(*args, **kwargs):
return f"this is the result of the first f() call at {dt.now().isoformat()}"
print(f())
print(f())
This will create a a sqlite database memo.sqlite, keeping track of function calls, and a text file 50/506f353d3ef92d51f3e57bae99367caf directory, containing the result of the first f() call. Obviously the timestamp from the first function call is preserved.
Changelog
Release 0.0.1
Description
Minimum Viable Product of a result caching function decorator.
Added
decorator cached: providing a caching mechanism for return values, so the function is not executed the next time when it is called with the same arguments.
class TextFileRepo: for caching return values of functions returning strings as text files in a configurable directory.
Release 0.1.0
Description
Multi-String support.
Changed
cached: returns a pair of datetime and original result, the former indicating the date of first submission; can handle functions/methods that return iterables.
Metadata
Release files for memoi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memoi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for memoi-0.1.0-py3-none-any.whl |
Release files / memoi-0.1.0-py3-none-any.whl
| Download URL | memoi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8b6867bf896f46ab3be5f6ebe4b49c5b268a8f8092e2c5a508fbc37e4c174c91
|
|
BLAKE2b-256 checksum How to use checksums |
096c95cca586d1bfade73ef7305cd94b9608ad2823afb4b2903239c4bda92a91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for memoi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.