Caching for Analytic Computations
Humans repeat stuff. Caching helps.
Normal caching policies like LRU aren't well suited for analytic computations where both the cost of recomputation and the cost of storage routinely vary by one million or more. Consider the following computations
# Want this
np.std(x) # tiny result, costly to recompute
# Don't want this
np.transpose(x) # huge result, cheap to recompute
Cachey tries to hold on to values that have the following characteristics
- Expensive to recompute (in seconds)
- Cheap to store (in bytes)
- Frequently used
- Recenty used
It accomplishes this by adding the following to each items score on each access
score += compute_time / num_bytes * (1 + eps) ** tick_time
For some small value of epsilon (which determines the memory halflife.) This has units of inverse bandwidth, has exponential decay of old results and roughly linear amplification of repeated results.
Example
>>> from cachey import Cache
>>> c = Cache(1e9, 1) # 1 GB, cut off anything with cost 1 or less
>>> c.put('x', 'some value', cost=3)
>>> c.put('y', 'other value', cost=2)
>>> c.get('x')
'some value'
This also has a memoize method
>>> memo_f = c.memoize(f)
Status
Cachey is new and not robust.
Metadata
Release files for cachey 0.2.1
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 |
|---|---|---|---|---|
| cachey-0.2.1.tar.gz | 6.5 kB | Without provenance | Details for cachey-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cachey-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for cachey-0.2.1-py3-none-any.whl |
Total release size: 12.9 kB
Release files / cachey-0.2.1.tar.gz
| Download URL | cachey-0.2.1.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0310ba8afe52729fa7626325c8d8356a8421c434bf887ac851e58dcf7cf056a6
|
|
BLAKE2b-256 checksum How to use checksums |
c69ce3c959c1601013bf8a72e8bf91ea1ebc6fe8a2305bd2324b039ee0403277
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.6
|
Release files / cachey-0.2.1-py3-none-any.whl
| Download URL | cachey-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49cf8528496ce3f99d47f1bd136b7c88237e55347a15d880f47cefc0615a83c3
|
|
BLAKE2b-256 checksum How to use checksums |
57f0e24f3e5d5d539abeb783087b87c26cfb99c259f1126700569e000243745a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.6
|
Security for cachey 0.2.1
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.