]> granicus.if.org Git - python/commitdiff
Issue #11628: cmp_to_key should use __slots__.
authorRaymond Hettinger <python@rcn.com>
Tue, 22 Mar 2011 00:50:28 +0000 (17:50 -0700)
committerRaymond Hettinger <python@rcn.com>
Tue, 22 Mar 2011 00:50:28 +0000 (17:50 -0700)
Lib/functools.py
Misc/NEWS

index 03de69ae161ad54e42d8ad3d5e8958237b44aca8..e92a2fcd68b97ad8305882933d79abe47313d43e 100644 (file)
@@ -96,6 +96,7 @@ def total_ordering(cls):
 def cmp_to_key(mycmp):
     """Convert a cmp= function into a key= function"""
     class K(object):
+        __slots__ = ['obj']
         def __init__(self, obj, *args):
             self.obj = obj
         def __lt__(self, other):
index 0bf7550864b1c8acd6222c207875693f2d36866f..5589daf850e9556169854b2001847d5d88be97ed 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #11628: cmp_to_key generated class should use __slots__
+
 - Issue #5537: Fix time2isoz() and time2netscape() functions of
   httplib.cookiejar for expiration year greater than 2038 on 32-bit systems.