[Python-Dev] PyObject_RichCompareBool identity shortcut
Terry Reedy
tjreedy at udel.edu
Thu Apr 28 22:48:48 CEST 2011
On 4/28/2011 12:55 PM, Guido van Rossum wrote:
> *If* my proposal gets accepted, there will be a blanket rule that no
> matter how exotic an type's __eq__ is defined, self.__eq__(self)
> (i.e., __eq__ called with the same *object* argument) must return True
> if the type's __eq__ is to be considered well-behaved;
This, to me, is a statement of the obvious ;-), but it should be stated
in the docs.
Do you also propose to make NaNs at least this well-behaved or leave
them ill-behaved?
> and Python
> containers may assume (for the purpose of optimizing their own
> comparison operations) that their elements have a well-behaved __eq__.
This almost states the status quo of the implementation, and the doc
needs to be updated correspondingly. I do not think we should let object
ill-behavior infect containers, so that they also become ill-behaved
(not equal to themselves).
--
Terry Jan Reedy
More information about the Python-Dev
mailing list