The Python Oracle

Contrary to Python 3.1 Docs, hash(obj) != id(obj). So which is correct?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Magic Ocean Looping

--

Chapters
00:00 Question
01:29 Accepted answer (Score 10)
01:55 Thank you

--

Full question
https://stackoverflow.com/questions/3027...

Accepted answer links:
[issue 5186]: http://bugs.python.org/issue5186

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #hash

#avk47



ACCEPTED ANSWER

Score 10


I'm guessing this was a change made in Python 3.x to improve performance. Check out issue 5186, then look a little more closely at your mismatched numbers:

>>> bin(11893680)
'0b101101010111101110110000'
>>> bin(743355)
'0b10110101011110111011'
>>> 11893680 >> 4
743355

It's probably worth reporting as a documentation bug.