Re: Recursion limit problems
- From: elventear <elventear@xxxxxxxxx>
- Date: 14 May 2007 12:05:15 -0700
On May 14, 1:20 pm, "Terry Reedy" <tjre...@xxxxxxxx> 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!
.
- References:
- Recursion limit problems
- From: elventear
- Re: Recursion limit problems
- From: elventear
- Re: Recursion limit problems
- From: Terry Reedy
- Recursion limit problems
- Prev by Date: Re: Recursion limit problems
- Next by Date: Re: Recursion limit problems
- Previous by thread: Re: Recursion limit problems
- Next by thread: Re: Recursion limit problems
- Index(es):
Relevant Pages
|