Terminology: "reference" versus "pointer"
steve at pearwood.info
Sat Sep 12 19:24:25 CEST 2015
On Sun, 13 Sep 2015 02:54 am, Rustom Mody wrote:
> This is from the docs
Yes, what of it? What point do you think you are making?
> Return the "identity" of an object. This is an integer which is
> guaranteed to be unique and constant for this object during its
> lifetime. Two objects with non-overlapping lifetimes may have the same
> id() value.
> CPython implementation detail: This is the address of the object in
What part of "CPython implementation detail" was too difficult for you to
id() is not an addressof function. It returns, and I quote:
"an integer which is guaranteed to be unique and constant for this object
during its lifetime"
which is *not the case for memory addresses*. Here are the IDs of a few
objects in Python:
steve at orac:~$ jython -c "print id(None); import sys; print id(sys)"
steve at orac:~$ ipy -c "print id(None); import sys; print id(sys)"
Are you going to argue that these are memory addresses? If not, what
relevance do you think the id() function has here?
Note: when I write my own Python implementation, all IDs will be negative
More information about the Python-list