Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d37fb55

Browse files
committed
Unique sentinel value for cache.get()
1 parent 6e8c817 commit d37fb55

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/functools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ def wrapper(*args, **kwds):
175175
# simple caching without ordering or size limit
176176
nonlocal hits, misses
177177
key = make_key(args, kwds, typed) if kwds or typed else args
178-
result = cache_get(key)
179-
if result is not None:
178+
result = cache_get(key, root) # root used here as a unique not-found sentinel
179+
if result is not root:
180180
hits += 1
181181
return result
182182
result = user_function(*args, **kwds)

0 commit comments

Comments
 (0)