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.11.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file memoiz-0.0.11.tar.gz
.
File metadata
- Download URL: memoiz-0.0.11.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 | 64ce8b1d3a4c64c4ba0c6818ac99aad6f9ca4004822473200cb9603ae21ceba9 |
|
MD5 | 395acfebc510ecaaf1c548be12a8b748 |
|
BLAKE2b-256 | 2c9eee4823c9d48a41fe78e976f9f066a3917ea7a5e4478d33ad577cd6361140 |
File details
Details for the file memoiz-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: memoiz-0.0.11-py3-none-any.whl
- Upload date:
- Size: 3.6 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 | 9cc256530133ea124d7a199bc74bb568e43c88fbfb2160ba6c0a17cb6bb3fa28 |
|
MD5 | a25d35f2b0c6c0fba4c1d7eec37af100 |
|
BLAKE2b-256 | 7d10bbb33d1c0aa48bb0fd3cf492a8c705073838d86582f9ece36e593af81ab7 |