On 11/19/2018 4:14 PM, Chris Barker via Python-Dev wrote:
On Mon, Nov 19, 2018 at 1:41 AM Antoine Pitrou <solip...@pitrou.net
<mailto:solip...@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.
This is what's in the docs now (3.8.0a0):
"""
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.
**CPython implementation detail:** For CPython, id(x) is the memory
address where x is stored.
"""
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.
"""
Well re-worded in my opinion.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com