1: origen: VALENTINO // MARTINA
2: destino: VALENTINO // MARTINA
3: Ayuda de la función copy()
4: Generic (shallow and deep) copying operations.
5:
6: Interface summary:
7:
8: import copy
9:
10: x = copy.copy(y) # make a shallow copy of y
11: x = copy.deepcopy(y) # make a deep copy of y
12:
13: For module specific errors, copy.Error is raised.
14:
15: The difference between shallow and deep copying is only relevant for
16: compound objects (objects that contain other objects, like lists or
17: class instances).
18:
19: - A shallow copy constructs a new compound object and then (to the
20: extent possible) inserts *the same objects* into it that the
21: original contains.
22:
23: - A deep copy constructs a new compound object and then, recursively,
24: inserts *copies* into it of the objects found in the original.
25:
26: Two problems often exist with deep copy operations that don't exist
27: with shallow copy operations:
28:
29: a) recursive objects (compound objects that, directly or indirectly,
30: contain a reference to themselves) may cause a recursive loop
31:
32: b) because deep copy copies *everything* it may copy too much, e.g.
33: administrative data structures that should be shared even between
34: copies
35:
36: Python's deep copy operation avoids these problems by:
37:
38: a) keeping a table of objects already copied during the current
39: copying pass
40:
41: b) letting user-defined classes override the copying operation or the
42: set of components copied
43:
44: This version does not copy types like module, class, function, method,
45: nor stack trace, stack frame, nor file, socket, window, nor array, nor
46: any similar types.
47:
48: Classes can use the same interfaces to control copying that they use
49: to control pickling: they can define methods called __getinitargs__(),
50: __getstate__() and __setstate__(). See the documentation for module
51: "pickle" for information on these methods.
52: