The copy module provides functions for making shallow and deep copies of compound objects, including lists, tuples, dictionaries, and class instances.
Makes a shallow copy of x by creating a new compound object and duplicating the members of x by reference.
deepcopy(x [, visit])
Makes a deep copy of x by creating a new compound object and recursively duplicating all the members of x.visit is an optional dictionary that’s used to keep track of visited objects in order to detect and avoid cycles in recursively defined data structures. This argument is typically only supplied if deepcopy() is being called recursively, as described later.
A class can implement its own copy methods by implementing the methods __copy__(self) and __deepcopy__ ...