It does not do copy-on-write.
It does not make a deep copy of some built-in immutable types, but any user-defined "immutable" types will be deeply copied.
copy.py in the Python 2.7 standard library contains this post in its documentation:
, , , , , , , , , , - .
copy :
def _copy_immutable(x):
return x
for t in (type(None), int, long, float, bool, str, tuple,
frozenset, type, xrange, types.ClassType,
types.BuiltinFunctionType, type(Ellipsis),
types.FunctionType, weakref.ref):
d[t] = _copy_immutable
for name in ("ComplexType", "UnicodeType", "CodeType"):
t = getattr(types, name, None)
if t is not None:
d[t] = _copy_immutable
deepcopy , , . , _deepcopy_tuple , , .
for i in range(len(x)):
if x[i] is not y[i]:
y = tuple(y)
break
else:
y = x