Re: Recursion limit problems



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!

.



Relevant Pages

  • Re: How to avoid rehashing?
    ... with strings. ... And keeping this in a hash. ... I use the words as keys since I want to find every occurence of the ... these hashes, which I need to do more than once. ...
    (perl.beginners)
  • Re: Get values from hash "in order"
    ... the same for every access to that hash. ... It is just that this sequence ... However, on an abstract level, hashes are a generalization of arrays. ... There is no such obvious sequence for strings. ...
    (comp.lang.perl.misc)
  • Re: Recursion limit problems
    ... exclusive or) the hash values for the components of the object that also ... Dicts first compare hashes and if they are equal, ... (given only 2**32 possible hashes and many more possible strings), ...
    (comp.lang.python)
  • Re: Advice needed: threads and queues
    ... >> Your hash contains strings, so what do you expect this to do? ... hash contains hashes, while your hash contain strings. ... If you had turned on strict, ...
    (comp.lang.perl.misc)
  • The certification password of Internet Explorer 7 and operation of auto complete
    ... About the certification password of Internet Explorer and operation ... By remembering the strings that are input in the following text ... In this registry, there are values whose name is a string of 42 bytes ... We cannot guess the original strings from the hash value, ...
    (Bugtraq)