memoization library for python 2.7

Is there any specific reason as why it is not available in 2.7?

@Nirk has already provided the reason: unfortunately, the 2.x line only receive bugfixes, and new features are developed for 3.x only.

Is there any 3rd party library providing the same feature?

repoze.lru is a LRU cache implementation for Python 2.6, Python 2.7 and Python 3.2.

Documentation and source code are available on GitHub.

Simple usage:

from repoze.lru import lru_cache

@lru_cache(maxsize=500)
def fib(n):
    if n < 2:
        return n
    return fib(n-1) + fib(n-2)

Leave a Comment