diff options
author | Raymond Hettinger <python@rcn.com> | 2016-12-16 21:59:32 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-12-16 21:59:32 (GMT) |
commit | c28dbd0452d54629328daaab0f80ad5391677d17 (patch) | |
tree | cb25b36c5db4db47e2ebb062d05603e2a12ac603 /Lib/functools.py | |
parent | 10a22dc65a7006e347df4d0b9f0bd0d946802786 (diff) | |
parent | af56e0e70f043ad2615eff403f46d7bc6c411aae (diff) | |
download | cpython-c28dbd0452d54629328daaab0f80ad5391677d17.zip cpython-c28dbd0452d54629328daaab0f80ad5391677d17.tar.gz cpython-c28dbd0452d54629328daaab0f80ad5391677d17.tar.bz2 |
merge
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 9845df2..45e5f87 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -574,14 +574,16 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo): last = root[PREV] link = [last, root, key, result] last[NEXT] = root[PREV] = cache[key] = link - full = (len(cache) >= maxsize) + # Use the __len__() method instead of the len() function + # which could potentially be wrapped in an lru_cache itself. + full = (cache.__len__() >= maxsize) misses += 1 return result def cache_info(): """Report cache statistics""" with lock: - return _CacheInfo(hits, misses, maxsize, len(cache)) + return _CacheInfo(hits, misses, maxsize, cache.__len__()) def cache_clear(): """Clear the cache and cache statistics""" |