]> granicus.if.org Git - python/commitdiff
Unique sentinel value for cache.get()
authorRaymond Hettinger <python@rcn.com>
Sat, 17 Mar 2012 00:04:11 +0000 (17:04 -0700)
committerRaymond Hettinger <python@rcn.com>
Sat, 17 Mar 2012 00:04:11 +0000 (17:04 -0700)
Lib/functools.py

index adc79274ca34860339de1a651527e58c4aa8272f..3eb55c6458b1065cfc59d69659220e6432c1b0a3 100644 (file)
@@ -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)