mirror of
https://github.com/python/cpython.git
synced 2025-09-02 23:18:25 +00:00
Unique sentinel value for cache.get()
This commit is contained in:
parent
6e8c817687
commit
d37fb55910
1 changed files with 2 additions and 2 deletions
|
@ -175,8 +175,8 @@ def lru_cache(maxsize=100, typed=False):
|
|||
# simple caching without ordering or size limit
|
||||
nonlocal hits, misses
|
||||
key = make_key(args, kwds, typed) if kwds or typed else args
|
||||
result = cache_get(key)
|
||||
if result is not None:
|
||||
result = cache_get(key, root) # root used here as a unique not-found sentinel
|
||||
if result is not root:
|
||||
hits += 1
|
||||
return result
|
||||
result = user_function(*args, **kwds)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue