The Python Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: The Builders

--

Chapters
00:00 Contrary To Python 3.1 Docs, Hash(Obj) != Id(Obj). So Which Is Correct?
01:12 Accepted Answer Score 10
01:31 Thank you

--

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

--

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.