...On Mon, Nov 19, 2018 at 1:41 AM Antoine Pitrou <solipsis@pitrou.net> wrote:
I'd rather keep the reference to memory addressing than start doing car
analogies in the reference documentation.
I agree -- and any of the car analogies will probably be only valid in some jurisdictions, anyway.
I think being a bit more explicit about what properties an ID has, and how the id() function works, and we may not need an anlogy at all, it's not that difficult a concept. And methions that in c_python the id is (currently) the memory address is a good idea for those that will wonder about it, and if there is enough explanation, folks that don't know about memory addresses will not get confused.
I agree that readers of a language reference should be able to manage without the analogies.I suggest something like the following:
"""Every object has an identity, a type and a value. An object’s identity uniquely identifies the object. It will remain the same as long as that object exists. No two different objects will have the same id at the same time, but the same id may be re-used for future objects once one has been deleted. The ‘is’ operator compares the identity of two objects; the id() function returns an integer representing its identity. ``id(object_a) == id(object_b)`` if and only if they are the same object.
**CPython implementation detail:** For CPython, id(x) is the memory address where x is stored.
"""