thinkings on shallow copy

Kendear kendear at nospam.com
Fri Jun 20 06:50:57 CEST 2003


John J. Lee wrote:
> Kendear <kendear at nospam.com> writes:
> [...]
> 
>>>>I wonder if it is actually to insert *the same object references*
>>>>into the new compound object...
>>>
>>>Sort of.  Better: "inserts references to the same objects".
>>>(Saying that the references are the same suggests, erroneously,
>>>that changing one reference would change the other:
>>
>>hm, why would it suggest that?  if two pointers are the
>>same, why would changing one pointer change the other?
> 
> 
> If two references are *the same* (ie. occupy the same location in
> memory), then of course changing one will change the other.  If they
> merely have the same value, then you'd be right.  Steven and me both
> interpret your use of the phrase 'the same object references' to mean
> the former.

hm, insert *the same object references* means, if the source
list's first item is 0x0123CDEF which is used as a pointer to memory
location 0x0123CDEF, then insert (set) the same value, 0x0123CDEF to
the target list's first item...  (say, 0x0123CDEF to 0x123FFFF
contains another list structure in memory).

so, insert *the same object references* and
"inserts references to the same objects" is the same thing
isn't it?  both set the list's first item to  0x0123CDEF

unless, you treat "reference" not as the number "0x0123CDEF"
but mean different thing or a higher level thing?  is reference
an object too in python?





More information about the Python-list mailing list