what is the keyword "is" for?

Dan Sommers me at privacy.net
Wed Aug 16 06:14:55 EDT 2006


On Wed, 16 Aug 2006 10:06:03 +0200,
Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:

> In [14]: a is b
> Out[14]: True

> In [15]: a == b
> Out[15]: False

> In [16]: a
> Out[16]: nan

> On my platform the division results in "Not A Number".  Two NaNs
> compared are always `False`.  You could argue that this is the very
> same NaN but to get this effect the interpreter has to take care that
> every NaN produced while a program is running is unique.  Quite huge
> overhead for such a corner case IMHO.

The interpreter isn't doing anything special; nans have [the equivalent
of] an __eq__ method that always returns False.

Regards,
Dan

-- 
Dan Sommers
<http://www.tombstonezero.net/dan/>
"I wish people would die in alphabetical order." -- My wife, the genealogist



More information about the Python-list mailing list