summaryrefslogtreecommitdiffstats
path: root/Lib/functools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2011-04-05 09:33:54 (GMT)
committerRaymond Hettinger <python@rcn.com>2011-04-05 09:33:54 (GMT)
commit7ab9e22e341603a1bf2fddd2eafa613bcd71b5cf (patch)
tree8444157bb22ce375730247924c9939a232a9c3ec /Lib/functools.py
parent271b27e5fe96c82fbb62ecc8034baa5aaf53d228 (diff)
downloadcpython-7ab9e22e341603a1bf2fddd2eafa613bcd71b5cf.zip
cpython-7ab9e22e341603a1bf2fddd2eafa613bcd71b5cf.tar.gz
cpython-7ab9e22e341603a1bf2fddd2eafa613bcd71b5cf.tar.bz2
Issue #11707: Fast C version of functools.cmp_to_key()
Diffstat (limited to 'Lib/functools.py')
-rw-r--r--Lib/functools.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/functools.py b/Lib/functools.py
index 3bffbac..098f6b6 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
@@ -115,6 +115,11 @@ def cmp_to_key(mycmp):
raise TypeError('hash not implemented')
return K
+try:
+ from _functools import cmp_to_key
+except ImportError:
+ pass
+
_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")
def lru_cache(maxsize=100):