Skip to main content

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


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.6.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

memoiz-0.0.6-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file memoiz-0.0.6.tar.gz.

File metadata

  • Download URL: memoiz-0.0.6.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.13

File hashes

Hashes for memoiz-0.0.6.tar.gz
Algorithm Hash digest
SHA256 2fa2a0dfd187a3c1d1d8a2bf0c71ca85c649f1ca86cab1f2f565869537ca502d
MD5 666f88956c2b675619743ce17443406d
BLAKE2b-256 1d03e5f57b3c5862adb77dd787a08278dd2e4035421fc3093a73e5571db110f9

See more details on using hashes here.

File details

Details for the file memoiz-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: memoiz-0.0.6-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.8.13

File hashes

Hashes for memoiz-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9565f98fb64f8276edadf07362381baa5d1bb753afbf2dede7f92847a4e97df1
MD5 98c27f4a43e8cf17d62b4fa80a53e54e
BLAKE2b-256 d1d225018a3b09c1cf25c1fd3835acaa0d078fa8dec94b13374daf5ace28805c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page