rest25/library/copy.rst => rest262/library/copy.rst
15Interface summary::
16
17   import copy
18
19   x = copy.copy(y)        # make a shallow copy of y
20   x = copy.deepcopy(y)    # make a deep copy of y
21
22For module specific errors, :exc:`copy.error` is raised.
n23- 
24-.. % 
25
26The difference between shallow and deep copying is only relevant for compound
27objects (objects that contain other objects, like lists or class instances):
28
29* A *shallow copy* constructs a new compound object and then (to the extent
30  possible) inserts *references* into it to the objects found in the original.
31
32* A *deep copy* constructs a new compound object and then, recursively, inserts
49* letting user-defined classes override the copying operation or the set of
50  components copied.
51
52This module does not copy types like module, method, stack trace, stack frame,
53file, socket, window, array, or any similar types.  It does "copy" functions and
54classes (shallow and deeply), by returning the original object unchanged; this
55is compatible with the way these are treated by the :mod:`pickle` module.
56
t55+Shallow copies of dictionaries can be made using :meth:`dict.copy`, and
56+of lists by assigning a slice of the entire list, for example,
57+``copied_list = original_list[:]``.
58+ 
57.. versionchanged:: 2.5
58   Added copying functions.
59
60.. index:: module: pickle
61
62Classes can use the same interfaces to control copying that they use to control
63pickling.  See the description of module :mod:`pickle` for information on these
64methods.  The :mod:`copy` module does not use the :mod:`copy_reg` registration
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op