[Python-checkins] cpython: Unique sentinel value for cache.get()
raymond.hettinger
python-checkins at python.org
Sat Mar 17 01:05:48 CET 2012
http://hg.python.org/cpython/rev/2d6eeb4ce0c8
changeset: 75758:2d6eeb4ce0c8
user: Raymond Hettinger <python at rcn.com>
date: Fri Mar 16 17:04:11 2012 -0700
summary:
Unique sentinel value for cache.get()
files:
Lib/functools.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Lib/functools.py b/Lib/functools.py
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -175,8 +175,8 @@
# 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)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list