hawkmoon269 schrieb:
some other languages' hash table (Perl's, for instance).  But FMU a
dictionary's keys are *themselves* hashed so that a hash table exists
that maps hashed key values to keys in the dictionary.

I guess you're mixing up the terms "hashing" and "storing in a hash-table".

When we hash a dictionary key

>>> a = hash(key)

then we retrieve a value that is used to refer to the value that we want to store. Ok? :)

1>>> mydict = {}
2>>> mydict['mykey'] = 'somevalue'
3>>> mydict['mykey']
'somevalue'

What happened, was:

1) mydict becomes a dictionary

2a) mydict hashed the key 'mykey' and got an integer value. Strings know how to calculate a hash value for themselves, that value is retrieved via a call to hash('mykey')

2b) mydict then stored the value 'myvalue' at a location that the hashed key refers to (don't care how that is done)

3) mydict hashes the key 'mykey' and retrieves an integer. It looks at the location that that int refers to and finds the value 'somevalue' that was previously stored there. It returns that value.

A bit clearer now?

Stefan
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to