1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Expand functools features to methods, classmethods, staticmethods and even for (unofficial) hybrid methods.
For now, methodtools only provides methodtools.lru_cache.
Use methodtools module instead of functools module. Than it will work as you expected.
from methodtools import lru_cache
class A(object):
# cached method. the storage lifetime follows `self` object
@lru_cache()
def cached_method(self, args):
...
# cached classmethod. the storage lifetime follows `A` class
@lru_cache() # the order is important!
@classmethod # always lru_cache on top of classmethod
def cached_classmethod(self, args):
...
# cached staticmethod. the storage lifetime follows `A` class
@lru_cache() # the order is important!
@staticmethod # always lru_cache on top of staticmethod
def cached_staticmethod(self, args):
...
@lru_cache() # just same as functools.lru_cache
def cached_function():
...
Installation
PyPI is the recommended way.
$ pip install methodtools
- To browse versions and tarballs, visit:
See also
[Documentation](https://methodtools.readthedocs.io/en/latest/)
This project is derived from Ring, a rich cache interface using the same method handling technique.
To learn more about bound method dispatching, see also [wirerope](https://github.com/youknowone/wirerope).
Release files for methodtools 0.4.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| methodtools-0.4.7.tar.gz | 3.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| methodtools-0.4.7-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 7.6 kB
Release files / methodtools-0.4.7.tar.gz
| Download URL | methodtools-0.4.7.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e213439dd64cfe60213f7015da6efe5dd4003fd89376db3baa09fe13ec2bb0ba
|
|
BLAKE2b-256 checksum How to use checksums |
133bc21b74ac17befdf17b286494b02221b7a84affb1d410ff86e38ba0e14b13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / methodtools-0.4.7-py2.py3-none-any.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | methodtools-0.4.7-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5e188c780b236adc12e75b5f078c5afb419ef99eb648569fc6d7071f053a1f11
|
|
BLAKE2b-256 checksum How to use checksums |
b64b6497ffb463b1b75e04b348ef31070606d43e3c503fa295383538ded999c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.1
|