Recursion limit problems

elventear elventear at gmail.com
Mon May 14 15:05:15 EDT 2007


On May 14, 1:20 pm, "Terry Reedy" <tjre... at udel.edu> wrote:
>
> Dicts first compare hashes and if they are equal, then check equality.  If
> two unequal strings have the same hash value, as is possible of course
> (given only 2**32 possible hashes and many more possible strings), both can
> still be used as different keys.  Ditto for unequal numbers.  Or for a
> number and string with equal hashes.  And so on.  The first quoted
> sentence, about mixing, is directed at minimizing such hash collisions.

Now my question is, since the definition mentions __cmp__ explicity.
Is that the only function it uses? What if __ne__, __eq__ are defined,
but not __cmp__?

Finally I am still confused about the inequality. Does dict only care
about the __cmp__ ouput being 0 and ignore the rest, or does it make
use of -1,1 as well? Could I just say that 0 defines equality in my
object and 1 otherwise, without regard of it being less than or
greater than?

Thanks!




More information about the Python-list mailing list