thinkings on shallow copy
John J. Lee
jjl at pobox.com
Fri Jun 20 03:29:40 CEST 2003
Kendear <kendear at nospam.com> writes:
> Steven Taschuk wrote:
> > Quoth Kendear:
> >>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
> essentially, "same object references" are the same as
> "references to the same objects"... just as
> "character pointer" is the same as "pointer to character"
> in C.
No, the two aren't analogous at all. It's what the 'same' refers to
that's confusing us, not the relative order of 'object' and
'reference' per se.
More information about the Python-list