summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2012-03-17 00:04:11 (GMT)
committerRaymond Hettinger <python@rcn.com>2012-03-17 00:04:11 (GMT)
commitd37fb559102d9c20786d8578a0362d1cd44aada2 (patch)
tree55a110bbd93fea6e3d719e3951abb13ee2348201
parent6e8c8176879915fa1f7d6f6d081136584f4bd315 (diff)
downloadcpython-d37fb559102d9c20786d8578a0362d1cd44aada2.zip
cpython-d37fb559102d9c20786d8578a0362d1cd44aada2.tar.gz
cpython-d37fb559102d9c20786d8578a0362d1cd44aada2.tar.bz2
Unique sentinel value for cache.get()
-rw-r--r--Lib/functools.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index adc7927..3eb55c6 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -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)