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

Skip to content

Commit 0a4edd5

Browse files
committed
Issue #11628: cmp_to_key should use __slots__.
2 parents 9c61e24 + a0d1d96 commit 0a4edd5

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

Lib/functools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def total_ordering(cls):
9696
def cmp_to_key(mycmp):
9797
"""Convert a cmp= function into a key= function"""
9898
class K(object):
99+
__slots__ = ['obj']
99100
def __init__(self, obj, *args):
100101
self.obj = obj
101102
def __lt__(self, other):

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ Library
8484
- Issue #11371: Mark getopt error messages as localizable. Patch by Filip
8585
Gruszczyński.
8686

87+
- Issue #11628: cmp_to_key generated class should use __slots__
88+
8789
- Issue #5537: Fix time2isoz() and time2netscape() functions of
8890
httplib.cookiejar for expiration year greater than 2038 on 32-bit systems.
8991

0 commit comments

Comments
 (0)