The module copy
exports two functions: copy()
and
deepcopy()
. The copy()
function returns a ``shallow''
copy of an object; deepcopy()
returns a ``deep'' copy. The
difference between shallow and deep copying is only relevant for
compound objects (objects that contain other objects, like lists or
class instances):
Both functions have the same restrictions and use the same protocols
as pickle
--- user-defined classes can control how they are
copied by providing methods named __getinitargs__()
,
__getstate__()
and __setstate__()
.