Tuples and underorderable types
Does anyone have any ideas about what to do with issue 5830 and handling the problem in a general way (not just for sched)? The basic problem is that decorate/compare/undecorate patterns no longer work when the primary sort keys are equal and the secondary keys are unorderable (which is now the case for many callables). >>> tasks = [(10, lambda: 0), (20, lambda: 1), (10, lambda: 2)] >>> tasks.sort() Traceback (most recent call last): ... TypeError: unorderable types: function() < function() Would it make sense to provide a default ordering whenever the types are the same? def object.__lt__(self, other): if type(self) == type(other): return id(self) < id(other) raise TypeError Raymond
participants (7)
-
"Martin v. Löwis"
-
Aahz
-
Antoine Pitrou
-
Daniel Diniz
-
Raymond Hettinger
-
Scott Dial
-
Terry Reedy