[Python-Dev] Why is nan != nan?
Alexander Belopolsky
alexander.belopolsky at gmail.com
Wed Mar 24 23:36:49 CET 2010
On Wed, Mar 24, 2010 at 6:31 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
..
> Neither is necessary, because Python doesn't actually use == as the
> equivalence relation for containment testing: the actual equivalence
> relation is: x equivalent to y iff id(x) == id(y) or x == y. This
> restores the missing reflexivity (besides being a useful
> optimization).
No, it does not:
>>> float('nan') in [float('nan')]
False
It would if NaNs were always interned, but they are not.
More information about the Python-Dev
mailing list