Why does None
hash to -1042159082
(which I found to be equal to number of bytes in a Gigabyte negated)?
I realize this doesn't really effect my code, but I'm curious.
Hashes are used for dictionary key look-ups, 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 type to see what's what. Is that right?
>>> {False: 'Hello', 0: 'Hi'}
{False: 'Hi'}
>>> {0: 'Hi', False: 'Hello'}
{0: 'Hello'}
This is just weird. What's more is that the first key is kept and the second value is kept.
Is this sorcery, or could somebody help me understand?