Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8cd2e5f

Browse files
committed
Sync-up minor code edits with the default branch.
1 parent 102d874 commit 8cd2e5f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/functools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def cmp_to_key(mycmp):
9797
"""Convert a cmp= function into a key= function"""
9898
class K(object):
9999
__slots__ = ['obj']
100-
def __init__(self, obj, *args):
100+
def __init__(self, obj):
101101
self.obj = obj
102102
def __lt__(self, other):
103103
return mycmp(self.obj, other.obj) < 0
@@ -140,7 +140,7 @@ def decorating_function(user_function,
140140
tuple=tuple, sorted=sorted, len=len, KeyError=KeyError):
141141

142142
hits = misses = 0
143-
kwd_mark = object() # separates positional and keyword args
143+
kwd_mark = (object(),) # separates positional and keyword args
144144
lock = Lock() # needed because ordereddicts aren't threadsafe
145145

146146
if maxsize is None:
@@ -151,7 +151,7 @@ def wrapper(*args, **kwds):
151151
nonlocal hits, misses
152152
key = args
153153
if kwds:
154-
key += (kwd_mark,) + tuple(sorted(kwds.items()))
154+
key += kwd_mark + tuple(sorted(kwds.items()))
155155
try:
156156
result = cache[key]
157157
hits += 1
@@ -170,7 +170,7 @@ def wrapper(*args, **kwds):
170170
nonlocal hits, misses
171171
key = args
172172
if kwds:
173-
key += (kwd_mark,) + tuple(sorted(kwds.items()))
173+
key += kwd_mark + tuple(sorted(kwds.items()))
174174
try:
175175
with lock:
176176
result = cache[key]

0 commit comments

Comments
 (0)