Shallow vs Deep copies [was Re: python assignment]
tjreedy at udel.edu
Thu Jul 24 00:11:54 CEST 2003
"Erik Max Francis" <max at alcyone.com> wrote in message
news:3F1EDFA0.ED78E04F at alcyone.com...
> immutable objects need not ever be literally copied
> Shallow copying makes a duplicate of the parent object. Deep
> makes a duplicate of everything.
To be more exact, because first statement is true,
second_statement.replace('everything', 'all mutables'),
which is to say, 'as much as needed'.
>>> import copy
>>> for i in l1+l2: print id(i)
7669904 #same ()
8428448 #different 
Terry J. Reedy
More information about the Python-list