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

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Oct 8 02:35:14 CEST 2012


On Thu, Oct 4, 2012 at 9:53 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> (Please do not start an argument about NANs and reflexivity. That's
> been argued to death, and there are very good reasons for the IEEE 754
> standard to define NANs the way they do.)

Why not?  This is python-ideas, isn't it?  I've been hearing that IEEE
754 committee had some "very good reasons" to violate reflexivity of
equality comparison with NaNs since I first learned about NaNs some 20
years ago.   From time to time, I've also heard claims that there are
some important numeric algorithms that depend on this behavior.
However, I've never been able to dig out the actual rationale that
convinced the committee that voted for IEEE 754 or any very good
reasons to preserve this behavior in Python.

I am not suggesting any language changes, but I think it will be
useful to explain why float('nan') != float('nan') somewhere in the
docs.  A reference to IEEE 754 does not help much.  Java implements
IEEE 754 to some extent, but preserves reflexivity of object equality.



More information about the Python-ideas mailing list