[Python-ideas] Disallow orderring comparison to NaN

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Apr 30 00:36:41 CEST 2011


On Fri, Apr 29, 2011 at 6:11 PM, Robert Kern <robert.kern at gmail.com> wrote:
..
> Well, for comparisons at least, it seems to have been anticipated, and
> returning a value was intentional. From the comments documenting
> float_richcompare() in floatobject.c:
>
> /* Comparison is pretty much a nightmare.  When comparing float to float,
>  * we do it as straightforwardly (and long-windedly) as conceivable, so
>  * that, e.g., Python x == y delivers the same result as the platform
>  * C x == y when x and/or y is a NaN.
>
Well, I may be overly pedantic, but this comment only mentions that
the author considered == comparison and not ordering of NaNs.   I
guess we need to ask Tim Peters if he considered the fact that x < NaN
is invalid operation according to IEEE 754 while x == NaN is not.
Tim?



More information about the Python-ideas mailing list