osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Explanation of list reference


Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
> 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:
>>>>    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?

Nowhere do I see the violating "x is y".

> All I need to do is show a case where two distinct objects have the
> same ID.

How do you know objects are "distinct"? Myself, I would use the "is"
test.

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

I am. I mean, "implementation-independent".

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

It is not defined at all:

   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.

Thus "x and y are identical" *means* "x is y" and nothing else.


Marko