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.7.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file memoiz-0.0.7.tar.gz
.
File metadata
- Download URL: memoiz-0.0.7.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6e1db846358cac306b9dc8c1e094b00de734d85a4148653d2f3a1dbe5d01706 |
|
MD5 | 7ddd55256ed50bd1688c39b857f41b00 |
|
BLAKE2b-256 | 563139f563e3c35681d160db84109cc221962be9224fb96b49e5de7f6a38a856 |
File details
Details for the file memoiz-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: memoiz-0.0.7-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4647a211174c0e470b445e3f024d65c511d803df644108539fc30ac1c02bf68e |
|
MD5 | 9c046c28162f6f5989f0d63a7f5c58a1 |
|
BLAKE2b-256 | 2e476971185e1906e0140ac74b0be5aef97089548810a14284e471b7e0c188b3 |