Why is the None hash equal to -1042159082 (which, it seemed to me, equal to the number of bytes in Gigabyte, is denied)?
I understand that this does not affect my code, but I'm curious.
Hashes are used to search for dictionary keys, so I decided to experiment:
>>> D = {-1042159082: 'Hello', None: 'Hi'} >>> D[None] 'Hi' >>> D[-1042159082] 'Hello' >>>
I understand this as Python, seeing two identical hashes, and then checking the type to find out what. Is it correct?
>>> {False: 'Hello', 0: 'Hi'} {False: 'Hi'} >>> {0: 'Hi', False: 'Hello'} {0: 'Hello'}
This is just weird. Moreover, the first key is stored and the second value is stored.
Is this magic, or can someone help me understand?
source share