I have the below dictionary:
>>> dict1={'a':1,'b':2}
>>>
>>>
>>> dict1['a']
1
>>>
Q: Is there a way to retrieve the value of key (in the above dictionary), using the hash value of the key?
If I print 'a'.__hash__ , I get:
>>> print 'a'.__hash__
<method-wrapper '__hash__' of str object at 0x00000000021AA0F8>
>>>
Q2: Why not do a key lookup directly rather than converting the key to a hash value and then do the lookup? I read that using hash makes it faster.
Objects/dictnotes.txtandObjects/dictobject.c. Then you will probably decide it is better to let Python do it.