# Explanation of list reference

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Feb 15 15:41:49 CET 2014

```On Sat, 15 Feb 2014 14:07:35 +0200, Marko Rauhamaa wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
>
>> On Sat, 15 Feb 2014 12:13:54 +0200, Marko Rauhamaa wrote:
>>>    0. x is x
>>>    1. if x is y then y ix x
>>>    2. if x is y and y is z then x is z
>>>    3. after x = y, x is y
>>>    4. if x is y and x == x, then x == y
>>>    5. id(x) == id(y) iff x is y
>>
>> # Counter-example
>> py> x = 230000
>> py> idx = id(x)
>> py> del x
>> py> y = 420000
>> py> idy = id(y)
>> py> idx == idy
>> True
>
> I don't accept that as a counterexample.

Why? Do you think I lied and just faked the output I put into my post? It
is a clear case where two distinct objects, in this case 230000 and
420000, have the same ID.

You cut out the explanation I gave explaining the example, which is
crucial. Your description of identity leaves out a critical factor,
namely that the objects being discussed must exist simultaneously. If you
don't specify that factor, your description includes a great big hole,
just as I show above.

> You will have to produce:
>
>    (id(x) == id(y)) == (x is y)
>    > False

I don't have to produce anything of the sort. All I need to do is show a
case where two distinct objects have the same ID. That is quite easy in
CPython, since IDs can be re-used after objects are garbage-collected.

>> (This is *implementation dependent* so your mileage my vary.)
>>
>>> Does that cover it?
>>
>> No. Your definition describes some properties of identity-equivalence,
>> but doesn't explain what identity actually means.
>
> That's the point. I don't think id() and "is" have any abstract meaning
> on top of the formal axioms.

Who is talking about "abstract meaning"? They have concrete meaning in
Python, and extremely simple meaning at that.

* id() is a function which returns an abstract implementation-
dependent identity number which is unique for each object

* The "is" operator compares the two operands for identity,
returning True if, and only if, they are the same object,
otherwise returning False.

Object identity is simple and well-defined in Python. I don't know why
you are so resistant to this. Read the documentation.

--
Steven

```