From: Raymond Hettinger Date: Sat, 17 Mar 2012 00:04:11 +0000 (-0700) Subject: Unique sentinel value for cache.get() X-Git-Tag: v3.3.0a2~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d37fb559102d9c20786d8578a0362d1cd44aada2;p=thirdparty%2FPython%2Fcpython.git Unique sentinel value for cache.get() --- diff --git a/Lib/functools.py b/Lib/functools.py index adc79274ca34..3eb55c6458b1 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)