diff options
author | Raymond Hettinger <python@rcn.com> | 2011-05-05 21:15:12 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2011-05-05 21:15:12 (GMT) |
commit | 8cd2e5f7512424354d2b3a05115d906d2def237a (patch) | |
tree | a5fbffd2979611d6a198183d36f20200b498928f /Lib | |
parent | 102d874999c7491b4c918d68ac3a0bf63e5cd9dc (diff) | |
download | cpython-8cd2e5f7512424354d2b3a05115d906d2def237a.zip cpython-8cd2e5f7512424354d2b3a05115d906d2def237a.tar.gz cpython-8cd2e5f7512424354d2b3a05115d906d2def237a.tar.bz2 |
Sync-up minor code edits with the default branch.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/functools.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/functools.py b/Lib/functools.py index 90642a5..03bcb1e 100644 --- a/Lib/functools.py +++ b/Lib/functools.py @@ -97,7 +97,7 @@ def cmp_to_key(mycmp): """Convert a cmp= function into a key= function""" class K(object): __slots__ = ['obj'] - def __init__(self, obj, *args): + def __init__(self, obj): self.obj = obj def __lt__(self, other): return mycmp(self.obj, other.obj) < 0 @@ -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] |