classification
Title: Documentation on deepcopy's problems is misleading
Type: Stage:
Components: Documentation Versions: Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, shlsh, steven.daprano
Priority: normal Keywords:

Created on 2014-08-30 07:41 by shlsh, last changed 2014-10-28 21:48 by georg.brandl. This issue is now closed.

Messages (3)
msg226123 - (view) Author: Shailesh Hegde (shlsh) Date: 2014-08-30 07:41
https://docs.python.org/<version>/library/copy.html

"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."

I believe the last line in above paragraph is missing a 'not' ahead of 'be shared'. 

It should read:
"administrative data structures that should be not shared even between copies"
msg226132 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2014-08-30 10:03
> It should read:
> "administrative data structures that should be not shared 
> even between copies"

No. If they should NOT be shared, then making a deep copy is the correct thing to do. The problem with deepcopy is when you actually do want to share some deep data structures, but not others. Then making a copy is the wrong thing, since they will no longer be shared.

The current documentation is correct. I'm going to leave the issue Open for the time being, in case somebody can think of wording that is more clear and less likely to be misunderstood.
msg226159 - (view) Author: Shailesh Hegde (shlsh) Date: 2014-08-31 04:42
Thanks.

"Because deep copy copies everything it may copy too much, e.g., administrative data structures that need to be shared even between copies, which may not be the desired goal."

helps me understand better.
History
Date User Action Args
2014-10-28 21:48:57georg.brandlsetstatus: open -> closed
2014-08-31 04:42:57shlshsetmessages: + msg226159
2014-08-30 10:03:31steven.dapranosetresolution: not a bug

messages: + msg226132
nosy: + steven.daprano
2014-08-30 07:41:40shlshcreate