Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @memoize decorator #31

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Add @memoize decorator #31

wants to merge 9 commits into from

Conversation

juharris
Copy link

@juharris juharris commented Jan 2, 2018

Example:

    @memoize(max_len=250, max_age_seconds=10)
    def fib(n):
        if n == 0:
            return 0
        elif n == 1:
            return 1
        return fib(n - 1) + fib(n - 2)

    assert 280571172992510140037611932413038677189525 == fib(200)

I'll add some docs and bump the version if the feature is wanted.

UPDATE: Not as important now that https://docs.python.org/3/library/functools.html#functools.lru_cache has been added. However, that method doesn't support eviction by age.

@juharris juharris closed this Jun 17, 2018
@juharris juharris reopened this Jun 17, 2018
@juharris
Copy link
Author

Any chance this can get merged?

@mailgun-ci
Copy link

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants