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

Uploaded Source

Built Distribution

memoiz-0.0.8-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for memoiz-0.0.8.tar.gz
Algorithm Hash digest
SHA256 bc722c42a2de272561b211f1f52c0ddc749ff1bea79e3ec01398037ec9f4f81d
MD5 e45a959ef83cf111d260c26642d97020
BLAKE2b-256 19335c48736c8f1f397d2cfd1acfe1a4d629b08cdc7b84e1358c507d23419e91

See more details on using hashes here.

File details

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

File metadata

  • Download URL: memoiz-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for memoiz-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0150550fdaf0ddf6c21c8919ea4120540d76184f209a56228d70f813da286d0a
MD5 bbb1017424885b0eef404265e18e7290
BLAKE2b-256 26e1e6411b968c95fc755af18268a2d04b057c322ceaba3575cdd11f13662c26

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