copy.deepcopy()
copy.deepcopy() is a Python function in the Copy Module category. Returns a deep copy of object x (recursively copies all nested objects). The syntax is copy.deepcopy(x, memo=None, _nil=[]). Parameters: x — any object. Returns: Deep copy. A typical example: import copy
orig = [1, [2, 3], 4]
cloned = copy.deepcopy(orig)
cloned[1].append(99) # Does NOT affect orig. A close sibling is copy.copy(), which returns a shallow copy of object x. Nested objects are not copied — they are referenced. More about this category: Shallow and deep copy operations — copy, deepcopy. Related Copy Module entries: copy.copy(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try copy.deepcopy() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.