What's the address for?

Chris Angelico rosuav at gmail.com
Mon Feb 18 15:06:27 EST 2019


On Tue, Feb 19, 2019 at 7:04 AM Avi Gross <avigross at verizon.net> wrote:
>
> Alister wrote about the meaning of the id number often displayed about a
> python object:
>
> > it is the internal id of the function - Not necessarily an address, that
> is an implementation detail.
>
> > it is not intended for use within a program & has (almost) no practical
> use.
>
> I hear that it is implementation dependent. But are there any requirements
> on the implementation that allow it to have meaning? I mean is the ID
> guaranteed to be unique and not reused within a session? If two things
> concurrently show the same ID, are they the same in some way?

Have you considered reading the docs?

https://docs.python.org/3/library/functions.html#id

"""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."""

I'm fairly sure that answers all your questions.

ChrisA



More information about the Python-list mailing list