[Python-Dev] Why is nan != nan? (original) (raw)

Stephen J. Turnbull stephen at xemacs.org
Fri Mar 26 05:39:55 CET 2010


Steven D'Aprano writes:

But unlike us, the equality operator only has a pinhole view of the operands. It can't distinguish between your example and this:

x = float('nan') y = some_complex_calculation(x) if x == y: ...

where y merely happens to end up with the same object as x by some quirk of implementation.

Note that Mark has already provided a related example of such a quirk (Decimal(-1).sqrt(), I think it was).



More information about the Python-Dev mailing list