mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
Adopt more descriptive attribute names as suggested on python-dev.
This commit is contained in:
parent
e9a4de51ab
commit
02566ec89f
5 changed files with 23 additions and 23 deletions
|
@ -142,23 +142,23 @@ def lru_cache(maxsize=100):
|
|||
with lock:
|
||||
result = cache[key]
|
||||
cache_renew(key) # record recent use of this key
|
||||
wrapper.hits += 1
|
||||
wrapper.cache_hits += 1
|
||||
except KeyError:
|
||||
result = user_function(*args, **kwds)
|
||||
with lock:
|
||||
cache[key] = result # record recent use of this key
|
||||
wrapper.misses += 1
|
||||
wrapper.cache_misses += 1
|
||||
if len(cache) > maxsize:
|
||||
cache_popitem(0) # purge least recently used cache entry
|
||||
return result
|
||||
|
||||
def clear():
|
||||
def cache_clear():
|
||||
"""Clear the cache and cache statistics"""
|
||||
with lock:
|
||||
cache.clear()
|
||||
wrapper.hits = wrapper.misses = 0
|
||||
wrapper.cache_hits = wrapper.cache_misses = 0
|
||||
|
||||
wrapper.hits = wrapper.misses = 0
|
||||
wrapper.clear = clear
|
||||
wrapper.cache_hits = wrapper.cache_misses = 0
|
||||
wrapper.cache_clear = cache_clear
|
||||
return wrapper
|
||||
return decorating_function
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue