Hash tables are supposed be high-performance mappings, and because Python dicts are implemented with hash tables, they're also highly performant. But I've encountered a strange result when looking at hash values of negative integers.
>>> for i in range(7):
... print hash(i-4)
...
-4
-3
-2
-2
0
1
2
But this apparently has no effect on dicts:
>>> d = dict()
>>> d[-1] = 'foo'
>>> d[-2] = 'bar'
>>> d
{-2: 'bar', -1: 'foo'}
Why does this happen, and why aren't dicts affected when I use them?