[Python-ideas] checking for identity before comparing built-in objects

MRAB python at mrabarnett.plus.com
Thu Oct 4 16:19:44 CEST 2012

On 2012-10-04 15:07, Mike Graham wrote:
> On Thu, Oct 4, 2012 at 10:02 AM, Mathias Panzenböck
> <grosser.meister.morti at gmx.net> wrote:
>> On 10/04/2012 03:53 PM, Steven D'Aprano wrote:
>>> py> NAN == NAN
>>> False
>> Why isn't this True anyway? Is there a PEP that explains this (IMHO odd)
>> behavior?
> IEEE 754 specifies this.
Think of it this way:

Calculation A returns NaN for some reason

Calculation B also returns NaN for some reason

Have they really returned the same result? Just because they're both
NaN doesn't mean that they're the _same_ NaN...

More information about the Python-ideas mailing list