comparing nan "number"

Michael Hudson mwh at python.net
Thu Dec 4 07:17:16 EST 2003


jjl at pobox.com (John J. Lee) writes:

> Michael Hudson <mwh at python.net> writes:
> 
> > jjl at pobox.com (John J. Lee) writes:
> > 
> > > Alexander Schmolck <a.schmolck at gmx.net> writes:
> > > [...]
> > > > possibly be `False` and {x:"some value}[x] might well raise an exception if
> > > > `x` is a nan (or indeed one of infinitely many Numeric arrays with
> > > [...]
> > > 
> > > Don't you mean SomeMapping((x, "some value"))[x]?  A dict lookup
> > > doesn't use __eq__.
> > 
> > Huh?  Yes it does (*after* __hash__, of course, but...).
> 
> Oh, collisions, right?

Yes.  You can't know a collision has (or has not) happened until after
you've tried __eq__...

Cheers,
mwh

-- 
  ARTHUR:  Why should a rock hum?
    FORD:  Maybe it feels good about being a rock.
                    -- The Hitch-Hikers Guide to the Galaxy, Episode 8




More information about the Python-list mailing list