don't need dictionary's keys - hash table?

Ganesan Rajagopal rganesan at myrealbox.com
Thu Jul 13 01:46:47 EDT 2006


>>>>> "Terry" == Terry Hancock <hancock at anansispaceworks.com> writes:

> Note that it is trivial to catch collisions on entry and correct them:

> key = hash(url_string)
> i      = 0
> if d.has_key(key):
>    while d.has_key(key):
>        i += 1

hash is a number. It's sufficient to do

while d.has_key(key):
    key += 1
   
> I am a little surprised that hash(hash(s)) == hash(s), is that actually
> true?

>>> hash(42)
42

Ganesan

-- 
Ganesan Rajagopal




More information about the Python-list mailing list