next up previous contents
Next: 11.5 Documentation Strings Up: 11.4 Object Persistency and Previous: 11.4.1 Persistent Objects

11.4.2 Copying Objects

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__().



guido@cnri.reston.va.us