summaryrefslogtreecommitdiff
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-03-18 15:09:10 -0700
committerRaymond Hettinger <python@rcn.com>2011-03-18 15:09:10 -0700
commit7e4c168385b5f723dbeb340abe51f7b99399e1c7 (patch)
tree0f1ee2d4eb03d764a2b526c0dc5697931491bbe3 /Lib/functools.py
parentf84f3c3d2dd02fa667ee8c89b9285e72a0d25aac (diff)
downloadcpython-git-7e4c168385b5f723dbeb340abe51f7b99399e1c7.tar.gz
Minor optimization -- factor a constant expression out of the inner-loop.
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 03de69ae16..fdc9c79098 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -140,7 +140,7 @@ def lru_cache(maxsize=100):
tuple=tuple, sorted=sorted, len=len, KeyError=KeyError):
hits = misses = 0
- kwd_mark = object() # separates positional and keyword args
+ kwd_mark = (object(),) # separates positional and keyword args
lock = Lock() # needed because ordereddicts aren't threadsafe
if maxsize is None:
@@ -151,7 +151,7 @@ def lru_cache(maxsize=100):
nonlocal hits, misses
key = args
if kwds:
- key += (kwd_mark,) + tuple(sorted(kwds.items()))
+ key += kwd_mark + tuple(sorted(kwds.items()))
try:
result = cache[key]
hits += 1
@@ -170,7 +170,7 @@ def lru_cache(maxsize=100):
nonlocal hits, misses
key = args
if kwds:
- key += (kwd_mark,) + tuple(sorted(kwds.items()))
+ key += kwd_mark + tuple(sorted(kwds.items()))
try:
with lock:
result = cache[key]