diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2019-01-31 23:03:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-31 23:03:38 (GMT) |
commit | ffdf1c30ab6940a5efe6f33e61678021d9fd14b6 (patch) | |
tree | 138f5c1c224f1c9fe01da04f2c60ce8c9c95ab36 /Lib/functools.py | |
parent | dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c (diff) | |
download | cpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.zip cpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.tar.gz cpython-ffdf1c30ab6940a5efe6f33e61678021d9fd14b6.tar.bz2 |
Consistently move the misses update to just before the user function call (GH-11715)
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 6233c30..fe47600 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -541,10 +541,10 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo): if maxsize == 0: def wrapper(*args, **kwds): - # No caching -- just a statistics update after a successful call + # No caching -- just a statistics update nonlocal misses - result = user_function(*args, **kwds) misses += 1 + result = user_function(*args, **kwds) return result elif maxsize is None: @@ -557,9 +557,9 @@ def _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo): if result is not sentinel: hits += 1 return result + misses += 1 result = user_function(*args, **kwds) cache[key] = result - misses += 1 return result else: |