[Python-Dev] == on object tests identity in 3.x

Terry Reedy tjreedy at udel.edu
Mon Jul 7 20:20:42 CEST 2014


On 7/7/2014 7:22 AM, Andreas Maier wrote:
> While discussing Python issue #12067
> (http://bugs.python.org/issue12067#msg222442), I learned that Python 3.4
> implements '==' and '!=' on the object type such that if no special
> equality test operations are implemented in derived classes, there is a
> default implementation that tests for identity (as opposed to equality
> of the values).
>
> The relevant code is in function do_richcompare() in Objects/object.c.
>
> IMHO, that default implementation contradicts the definition that '=='
> and '!=' test for equality of the values of an object.

A discrepancy between code and doc can be solved by changing either the 
code or doc. This is a case where the code should not change (for back 
compatibility with long standing behavior, if nothing else) and the doc 
should.

-- 
Terry Jan Reedy



More information about the Python-Dev mailing list