mirror of https://github.com/python/cpython.git
Unique sentinel value for cache.get()
This commit is contained in:
parent
6e8c817687
commit
d37fb55910
|
@ -175,8 +175,8 @@ def wrapper(*args, **kwds):
|
||||||
# simple caching without ordering or size limit
|
# simple caching without ordering or size limit
|
||||||
nonlocal hits, misses
|
nonlocal hits, misses
|
||||||
key = make_key(args, kwds, typed) if kwds or typed else args
|
key = make_key(args, kwds, typed) if kwds or typed else args
|
||||||
result = cache_get(key)
|
result = cache_get(key, root) # root used here as a unique not-found sentinel
|
||||||
if result is not None:
|
if result is not root:
|
||||||
hits += 1
|
hits += 1
|
||||||
return result
|
return result
|
||||||
result = user_function(*args, **kwds)
|
result = user_function(*args, **kwds)
|
||||||
|
|
Loading…
Reference in New Issue