mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Consistently move the misses update to just before the user function call (GH-11715)
This commit is contained in:
parent
dcfcd146f8
commit
ffdf1c30ab
2 changed files with 8 additions and 6 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue