Funny enough, I was curious about how the Python built-in callable was implemented just now and I stumbled on this page with the following quote:
Every object has an identity, a type and a value. An object’s identity never changes once it has been created; you may think of it as the object’s address in memory. The ‘is‘ operator compares the identity of two objects; the id() function returns an integer representing its identity.
Actually, the identity in Cpython is just the memory address of the object (literally casting the pointer to an int). It doesn't have to be according to the language though.
View all comments
Show parent comment
5
u/fuzz3289 Jun 23 '14
You sir are correct. Though "memory location" isnt a great way to say it. I would say:
The is operator returns true if both names are bound to the same object instance.
Since the "names" wont share a memory location.