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

Consider replacing memoized functions with lru_cache #174

Open
nrejac opened this issue May 18, 2021 · 0 comments
Open

Consider replacing memoized functions with lru_cache #174

nrejac opened this issue May 18, 2021 · 0 comments

Comments

@nrejac
Copy link
Contributor

nrejac commented May 18, 2021

Python 3.2 now includes memoization in the functools module. It's implemented in C, and using it is simple:

import functools

@functools.lru_cache()
def fib_lru_cache(n):
    if n < 2:
        return n
    else:
        return fib_lru_cache(n - 2) + fib_lru_cache(n - 1)

Consider replacing the memoization functions implemented in: idb/helpers/memoize.py with the new, standard lru_cache. Then, adjust the existing calls to memoized functions to use the new lru_cache.

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

No branches or pull requests

1 participant