[Python-ideas] checking for identity before comparing built-in objects

Terry Reedy tjreedy at udel.edu
Mon Oct 8 22:51:14 CEST 2012


On 10/8/2012 12:19 PM, Guido van Rossum wrote:

> I am not aware of an update to the standard. Being 20 years old does
> not make it outdated.

Similarly, being hundreds or thousands of years old does not make the 
equality standard, which includes reflexivity of equality, outdated. The 
IEEE standard violated that older standard.
http://bugs.python.org/issue4296
illustrates some of the problems than come with that violation. But 
given the compromise made to maintain sane behavior of Python's 
collection classes, I see little reason to change nan in isolation.

I wonder if it would be helpful to make a NaN subclass of floats with 
its own arithmetic and comparison methods. This would clearly mark a nan 
as Not a Normal float. Since subclasses rule (at least some) binary 
operations*, this might also simplify normal float code. But perhaps 
this was considered and rejected before adding math.isnan in 2.6. (And 
ditto for infinities.)

* in that class_ob op subclass_ob is delegated to subclass.__op__, but I 
am not sure if this applies only to arithmetic, comparisons, or both.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list