[Python-ideas] Why is nan != nan?
Stephen J. Turnbull
stephen at xemacs.org
Sat Mar 27 16:46:57 CET 2010
Marcin 'Qrczak' Kowalczyk writes:
> The original problem with NaN is a consequence of an unfortunate
> decision to unify numeric equality with object equivalence. If they
> were distinguished, their behavior would be obvious:
> NaN != NaN
> NaN eq NaN
What do you mean by that? NaN is a class, not an instance!
> 0.0 == -0.0
> 0.0 ne -0.0
> 42 == 42.0
> 42 ne 42.0
As for the other examples, I can only sigh, 'Ah, the joys of "general
abstract nonsense".'[1] I have some (abstract) sympathy for Mark's
proposal for a with_nonstop_arithmetic context manager, but isn't it
really a YAGNI for the Python language? (As opposed to high
performance modules like numpy.)
Footnotes:
[1] I refer to Bourbaki's(?) name for category theory.
More information about the Python-ideas
mailing list