Object identity has no necessary connection to memory location (was: What is a function parameter =[] for?)

Ben Finney ben+python at benfinney.id.au
Thu Nov 26 06:24:25 EST 2015


Dave Farrance <df at see.replyto.invalid> writes:

> Marko Rauhamaa <marko at pacujo.net> wrote:
>
> >Dave Farrance <df at see.replyto.invalid>:
> >
> >> (Conversely, I see that unlike CPython, all PyPy's numbers have
> >> unchanging ids, even after exiting PyPy and restarting, so it seems
> >> that PyPy's numerical ids are "faked".)
> >
> >What's a faked id?
>
> You can figure out what I'm getting at -- i.e. I presume that the ids
> are not pointers to stored numbers in memory (as with CPython) but are
> a translation of the numerical variable's value.

Why refer to that as “faked”? That's what I can't figure out about what
you're getting at. Perhaps Marko shares my uncomprehension.

The Python language makes no promise about “pointers to stored numbers
in memory” for object identity. That is an implementation detail of
CPython, and is *explicitly* not promised for any other Python
implementation.

If you are surprised that object identity appears to have no connection
with memory location, then you've made unwarranted assumptions that are
explicitly warned against in the Python documentation.

-- 
 \        “Absurdity, n. A statement or belief manifestly inconsistent |
  `\            with one's own opinion.” —Ambrose Bierce, _The Devil's |
_o__)                                                Dictionary_, 1906 |
Ben Finney




More information about the Python-list mailing list