Raymond Hettinger wrote: > 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
No. This only makes it more difficult for someone wanting to behave smartly with incomparable types. I can easily imagine someone wanting incomparable objects to be treated as equal wrt. sorting. I am thinking especially with respect to keeping the sort stable. I think many developers would be surprised to find, >>> a = >>> tasks = [(10, lambda: 0), (20, lambda: 1), (10, lambda: 2)] >>> tasks.sort() >>> assert tasks[0][1]() == 0 , is not guaranteed. Moreover, I fail to see your point in general as a bug if you accept that there is not all objects can be total ordered. We shouldn't be patching the object base class because of legacy code that relied on sorting tuples; this code should be updated to either use a key function. -Scott -- Scott Dial sc...@scottdial.com scod...@cs.indiana.edu _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com