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

Uploaded Source

Built Distribution

memoiz-0.0.10-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for memoiz-0.0.10.tar.gz
Algorithm Hash digest
SHA256 0e586862529ff3feb18ba6b92ee69b1c19440df61acf97844288eadfde898f93
MD5 7eed8d8d2384cc54d0785dc660a85b1f
BLAKE2b-256 8c9662c98a0b45e16253340b3c1f35797f8aa47c1fb666ae0967e03fdd5ee7eb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memoiz-0.0.10-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

Hashes for memoiz-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 afe0c6105d5e807db25abab35c71b55bedb06089402dc7e9c34097566669df6a
MD5 f5e9b4c5ffeff15a28f77750aac4ee56
BLAKE2b-256 fdeb2bf78be2642a5e6bedfca4f8827566ea3aa1c39a6a1418a6f9f72f7bd5f0

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