[Python-Dev] PyObject_RichCompareBool identity shortcut

Nick Coghlan ncoghlan at gmail.com
Wed Apr 27 14:20:46 CEST 2011


2011/4/27 Ɓukasz Langa <lukasz at langa.pl>:
> # Or even:
>>>> inf+1 == inf-1
> True
>
> For the infinity part, I believe this is related to the funky IEEE 754 standard. I found
> some discussion about this here: http://compilers.iecc.com/comparch/article/98-07-134

The inf behaviour is fine (inf != inf only when you start talking
about aleph levels, and IEEE 754 doesn't handle those).

It's specifically `nan` that is problematic, as it is one of the very
few cases that breaks the reflexivity of equality.

That said, the current behaviour was chosen deliberately so that
containers could cope with `nan` at least somewhat gracefully:
http://bugs.python.org/issue4296

Issue 10912 added an explicit note about this behaviour to the 3.x
series documentation, but that has not as yet been backported to 2.7
(I reopened the issue to request such a backport).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list