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

Explanation of list reference

On 2/15/2014 1:07 AM, Rustom Mody wrote:
> On Saturday, February 15, 2014 10:50:35 AM UTC+5:30, Ian wrote:
>> On Fri, Feb 14, 2014 at 9:24 PM, Rustom Mody  wrote:
>>> In the case of physical objects like dice there is a fairly
>>> unquestionable framing that makes identity straightforward --
>>> 4-dimensional space-time coordiantes. If the space-time coordinates of
>>> 2 objects are all equal then the objects are identical, else not.
>>> Now we analogize the space-time identity of physical objects to
>>> computer identity of computer objects (so-called) and all sorts of
>>> problems ensue.
>>> To start with we say two objects are identical if they have the same
>>> memory address.
>> This is false.  It happens to hold for CPython, but that's an
>> implementation detail.  The definition of object identity does not
>> depend on memory address.  It also doesn't have anything to do with
>> space-time coordinates.  The concept of object identity is an
>> abstraction, not an analogy from physics.
>> The language reference states, "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."
>> Okay, so that quote does bring up memory address, but in my
>> interpretation that's just an analogy to introduce the concept.  The
>> more important part of that sentence is the first part, which ties an
>> object's identity to its creation.  If two objects share the same
>> creation, then they're the same object.
> Whats the notion of object identity is the question.
> Ok so you reject the memory addr as an 'implementation detail'
> Then you are obliged to provide some other way of understanding object-identity

'Identity' is an abstraction. For immutable objects, it is essentially 
irrelevant. For mutable objects, it is essential in the following sense. 
  A and B are the same object if mutating A necessarily mutates B and 
different if they can be independently mutated.

The id() of an object is a fixed integer that is temporally unique. An 
implementation might use the id to access objects. When one executes 
Python mentally, one might skip implementing id(). Its main use is to 
test an implementation. Most beginners should ignore it.

Terry Jan Reedy