[Tutor] lists, name semantics

boB Stepp robertvstepp at gmail.com
Sun Apr 19 06:26:02 CEST 2015


On Sat, Apr 18, 2015 at 11:08 PM, Cameron Simpson <cs at zip.com.au> wrote:

> Sometimes you want a "deep" copy, where "b" would have got a copy of the
> iriginal x-y list. See the "copy" module's "deepcopy" function, which
> supplies this for when it is needed:
>
>  https://docs.python.org/3/library/copy.html#copy.deepcopy

In this reference, part of it states:

"Two problems often exist with deep copy operations that don’t exist
with shallow copy operations:

Recursive objects (compound objects that, directly or indirectly,
contain a reference to themselves) may cause a recursive loop.
Because deep copy copies everything it may copy too much, e.g.,
administrative data structures that should be shared even between
copies."

If I am understanding things correctly, should not that last sentence
read instead:

"...structures that should *not* be shared even between copies." ???

-- 
boB


More information about the Tutor mailing list