diff options
author | Raymond Hettinger <python@rcn.com> | 2012-03-16 17:04:11 -0700 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2012-03-16 17:04:11 -0700 |
commit | 8f8f9ebfddbf0e1901ec1e567ec57718a66330cd (patch) | |
tree | cd01df71a499b320bfed09cfdfb790c0dd9d3bc3 /Lib/functools.py | |
parent | 8851974f636823b6e78e83efadf661a6fa8b7670 (diff) | |
download | cpython-8f8f9ebfddbf0e1901ec1e567ec57718a66330cd.tar.gz |
Unique sentinel value for cache.get()
Diffstat (limited to 'Lib/functools.py')
-rw-r--r-- | Lib/functools.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index adc79274ca..3eb55c6458 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) |