[Python-Dev] PyObject_RichCompareBool identity shortcut

Glenn Linderman v+python at g.nevcal.com
Thu Apr 28 06:52:55 CEST 2011


On 4/27/2011 7:31 PM, Stephen J. Turnbull wrote:
> Glenn Linderman writes:
>
>   >  I would not, however expect the original case that was described:
>   >   >>>  nan = float('nan')
>   >   >>>  nan == nan
>   >  False
>   >   >>>  [nan] == [nan]
>   >  True                  # also True in tuples, dicts, etc.
>
> Are you saying you would expect that
>
>>>> nan = float('nan')
>>>> a = [1, ..., 499, nan, 501, ..., 999]    # meta-ellipsis, not Ellipsis
>>>> a == a
> False
>
> ??

Yes, absolutely.  Once you understand the definition of NaN, it 
certainly cannot be True.   a is a, but a is not equal to a.

> I wouldn't even expect
>
>>>> a = [1, ..., 499, float('nan'), 501, ..., 999]
>>>> b = [1, ..., 499, float('nan'), 501, ..., 999]
>>>> a == b
> False
>
> but I guess I have to live with that.<wink>   While I wouldn't apply it
> to other people, I have to admit Raymond's aphorism applies to me (the
> surprising thing is not the behavior of NaNs, but that I'm surprised
> by anything that happens in the presence of NaNs!)

The only thing that should happen in the presence of NaNs is more NaNs :)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110427/9585afbb/attachment.html>


More information about the Python-Dev mailing list