Memoiz is a memoization decorator that makes resonable assumptions about how and if to cache the return value of a function or method based on the arguments passed to it. The decorator can be used on both free and bound functions.
Project description
Memoiz
Memoiz is a memoization decorator that makes resonable assumptions about how and if to cache the return value of a function or method based on the arguments passed to it. The decorator can be used on both free and bound functions.
Usage
from memoiz.cache import Cache
cache = Cache()
class Example:
def __init__(self):
self.n = 1
@cache
def test(self, a, b):
return (self.n, a, b)
example = Example()
example.test(1, 2)
cache.invalidate(example.test, example, 1, 2)
@cache
def test(a):
return a
test(1)
cache.invalidate(test, 1)
Install
pip install memoiz
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
memoiz-0.0.9.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file memoiz-0.0.9.tar.gz
.
File metadata
- Download URL: memoiz-0.0.9.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 508d81b5854cb28a047d885cec752e4ec4e9a50a5dd442d83fc31dce25add107 |
|
MD5 | af464751566cdb12491f2351bfaf388e |
|
BLAKE2b-256 | 5a7ec377724838098bb3c1a1feda282b96569d4e64e21897ddb23e48c97436b2 |
File details
Details for the file memoiz-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: memoiz-0.0.9-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3404c0bf647eea520d317e1cd080334d0522f7a24255ac4552a4558856920568 |
|
MD5 | 86f70b5b22995b4f4cb8dc2a0f35b02b |
|
BLAKE2b-256 | c40fb2620669ecb84c939c0842e487afb7d2e6ab48c91096bc6b35253822fc4a |