No project description provided
Project description
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.
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
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 cachemethod-0.1.0.tar.gz.
File metadata
- Download URL: cachemethod-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea08fa39a98b126ea6f34935dd1489c18b97a8c8f1c3a0f20f090ff7eef93a12
|
|
| MD5 |
00080f8fc2249526f2924676c7b7df0d
|
|
| BLAKE2b-256 |
23b96a483ffc4961ef604ae74f13fcd5d6857c50dc28ac1bd6e3cf625626e266
|
File details
Details for the file cachemethod-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cachemethod-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2136f7a95ce392e9859242850001b4b724c8c845b9e111e06e60a0e17a57766
|
|
| MD5 |
9161cbe8e8fc0241745ba49c92825969
|
|
| BLAKE2b-256 |
52a90ad7a063c867413405826a78481606d43b2933e0b2b417d2fda33ecf7596
|