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

Uploaded Source

Built Distribution

memoiz-0.0.11-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

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