Cache results for re-use
Project description
Result Caching
Stores function results so that they are not computed again on repetitive calls of the function with the same arguments. Results can be stored either on disk or in memory.
Quick setup
pip install git+https://github.com/mschrimpf/result_caching
Usage example
from result_caching import store
@store()
def f(a, b):
return a * b
y = f(1, 2) # computed first time, stored on disk
y = f(1, 2) # not computed again, loaded from disk
y = f(1, 3) # computed again, different parameters
By default, results will be stored in ~/.result_caching, this can be
changed through the environment variable RESULTCACHING_HOME.
cache will only hold results in memory and not write them to disk.
Environment variables
| Variable | description |
|---|---|
| RESULTCACHING_HOME | directory to cache results (benchmark ceilings) in, ~/.result_caching by default |
| RESULTCACHING_DISABLE | * '1' to disable loading and saving of results, functions will be called directly |
* 'candidate_models.score_model,model_tools.activations' to disable loading and saving of function identifiers starting with one of the specifiers separated by a comma (e.g. any package or function inside model_tools.activations will not be considered) |
|
| RESULTCACHING_CACHEDONLY | If enabled, raises an error when trying to run a function that does not have its result already cached (follows the same matching rules as RESULTCACHING_DISABLE) |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file result_caching-0.1.0.tar.gz.
File metadata
- Download URL: result_caching-0.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a25fae870ef8e0303c1be8ff6d6131138c0c300ce6879910e5f588a28d6530c
|
|
| MD5 |
b2ea397898c96d402e95a7b4926bdb05
|
|
| BLAKE2b-256 |
bc722a5158658fa567c23a7acd7feec812dae0f0ef5da03ecf589709f07f4955
|
File details
Details for the file result_caching-0.1.0-py3-none-any.whl.
File metadata
- Download URL: result_caching-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cccecffd6531cc2a3d7d6e14002e05d74a41bbf53e2774621327e3d8a7ac46d
|
|
| MD5 |
e02da6a030249e93c520a522ecb1afc9
|
|
| BLAKE2b-256 |
5163e1ae17c4c61f20d94ec0fba155488f0ca6cc60631612df3340caf21e6898
|