rez.backport.lru_cache

This lru cache implementation is based on the backport of the pure python lru cache in Python 3 and found on the ActiveState website:

http://code.activestate.com/recipes/578078-py26-and-py30-backport-of-python-33s-lru-cache/

It has been modified to remove the cache info (data on cache hits and misses) and implementt a simplified _make_key method. Both of these give modest improvements in performance, reducing the time spent in the wrapper function by ~30-40%. Both of theses changes are based on discussions in the Python bug tracker:

http://bugs.python.org/issue16389 http://bugs.python.org/issue14373

rez.backport.lru_cache.lru_cache(maxsize=100)[source]

Least-recently-used cache decorator.

If maxsize is set to None, the LRU features are disabled and the cache can grow without bound.

Arguments to the cached function must be hashable.

View the cache statistics named tuple (hits, misses, maxsize, currsize) with f.cache_info(). Clear the cache and statistics with f.cache_clear(). Access the underlying function with f.__wrapped__.

See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used