cachemethod
python's missing cache functionality, you can cache a regular function
you can cache staticmethod and classmethod but you can't really cache a method that takes self.
pip3 install cachemethod
why can't I use cache on a method that takes self?
python cache doesn't actually stores the hash of the *args and *kwargs (including self), but it
puts it into a tuple (which is hashable) and that tuple is used as a key in the cache dict, thus
storing the reference to self in that tuple causes the instance to be a live until the cache is cleared
or it runs of our space (if you use lru_cache)
why not just hash the items then?
the default hash implementation for classes uses the allocated memory for instances,
so if an instance memory gets freed, the cache is not really valid anymore but it is still
in the cache dict, so instance that was created on the same memory and passed the same arguments
can hit the cache and cause unexpected results
how this package solves the issue
it creates a seed which is a random integer and attaches it to the instance, based on that seed caching is done
not relying on the class hash and not storing references
Metadata
Release files for cachemethod 1.0.0
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 |
|---|---|---|---|---|
| cachemethod-1.0.0.tar.gz | 2.7 kB | Without provenance | Details for cachemethod-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cachemethod-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for cachemethod-1.0.0-py3-none-any.whl |
Total release size: 5.8 kB
Release files / cachemethod-1.0.0.tar.gz
| Download URL | cachemethod-1.0.0.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5da4f883532ec737d3838779933eb19967e53ccaa2012844783751369b86c65a
|
|
BLAKE2b-256 checksum How to use checksums |
41b672c7093d914e9608dd18a17769f8bc3cdafaa713631dc6d206e154a5ecbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.10.3-arch1-2
|
Release files / cachemethod-1.0.0-py3-none-any.whl
| Download URL | cachemethod-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fa1caac59184dbd3d9b29fb87ea2f8b50bdcf9f1e8e43d36207ed3b0ff2602c
|
|
BLAKE2b-256 checksum How to use checksums |
2c89240087e484a6f3b0c5645f071f8378d954cd1d80aadf6e88cbb83dda9bb4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.10.3-arch1-2
|
Security for cachemethod 1.0.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.