Pickle function cache
Allows for caching of the results of function calls in a
file using pickle (builtin shelve did not
work for some reason and marshal was not considered;
json was not able to serialize all the things I needed).
- the file read happens only once per process per filename (all the function caches in the same cache file are loaded once)
- if the result is not found in the cache, the result is computed using the original function and is written into the cache file and to the runtime cache.
- if the result for the same set of arguments is requested and found the original function is not called but the cached result is returned.
Usage
from pickle_function_cache import cache_responses
@cache_responses("cache.dat")
def f1(param1, param2):
... # take a lot of time
@cache_responses("cache.dat")
def f2(param1, param2, param3):
... # take a lot of time
# use function normally ...
- when first called,
f1(1,2)computes the result using the original, f1 - afterwards
f1(1,2)returns the cached result, omitting the function call - if you call
f2(1,2,3), it will be no trouble because function caches are stored separately per function name in the same file (note: cached function names should be unique)
Configuration
You can set the env var OMIT_PICKLE_FUNCTION_CACHE to either 1 or true
to disable the cache at compile time without changing the code.
Performance
The cache was tested on a small set of quick functions and a small test list of examples and did not introduce a significant overhead. Probably, if the chosen functions for cache were more computationally intensive, we would see a speed-up because of the cache.
Metadata
Release files for pickle-function-cache 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pickle_function_cache-0.1.7.tar.gz | 15.0 kB | Without provenance | Details for pickle_function_cache-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pickle_function_cache-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for pickle_function_cache-0.1.7-py3-none-any.whl |
Total release size: 30.8 kB
Release files / pickle_function_cache-0.1.7.tar.gz
| Download URL | pickle_function_cache-0.1.7.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e3fb07c59b2b4a41313f4d13e2b762e6a70b8d1bb001086bc39cfc4cb945819
|
|
BLAKE2b-256 checksum How to use checksums |
f6d85f65455991de0daaebd68b2cf7d77a06a049a926518878849d01cac1835c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / pickle_function_cache-0.1.7-py3-none-any.whl
| Download URL | pickle_function_cache-0.1.7-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67ddb29186dc3043ec2fa69b65cd48781e9b17cf8ceb85085477e60a7baa0dd0
|
|
BLAKE2b-256 checksum How to use checksums |
eb2b282809375de70cc4e21bbdbe957496f2751ceb772e96f3d8d6036f1b3b4f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for pickle-function-cache 0.1.7
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.