although it is not usually necessarya class can implement customized copy methods by implementing the methods _copy_ (selfand _deepcopy_ (selfvisit)which implement the shallow and deep copy operations respectively the _deepcopy_ (method must accept dictionaryvisitwhich is used to keep track of previously encountered objects during the copy process it' not necessary for _deepcopy_ (to do anything with visit other than pass it to other deepcopy(operations carried out in the implementation (if anyif class implements the methods _getstate_ (and _setstate_ (that are used by the pickle modulethey will be used by the copy module to create copies notes this module can be used with simple types such as integers and stringsbut there' little need to do so the copy functions don' work with modulesclass objectsfunctionsmethodstracebacksstack framesfilessocketsand other similar types when an object can' be copiedthe copy error exception is raised gc the gc module provides an interface for controlling the garbage collector used to collect cycles in objects such as liststuplesdictionariesand instances as various types of container objects are createdthey're placed on list that' internal to the interpreter whenever container objects are deallocatedthey're removed from this list if the number of allocations exceeds the number of deallocations by user-definable threshold valuethe garbage collector is invoked the garbage collector works by scanning this list and identifying collections of objects that are no longer being used but haven' been deallocated due to circular dependencies in additionthe garbage collector uses threelevel generational scheme in which objects that survive the initial garbage-collection step are placed onto lists of objects that are checked less frequently this provides better performance for programs that have large number of long-lived objects collect([generation]runs full garbage collection this function checks all generations and returns the number of unreachable objects found generation is an optional integer in the range that specifies the generation to collect disable(disables garbage collection enable(enables garbage collection garbage variable containing read-only list of user-defined instances that are no longer in usebut which cannot be garbage collected because they are involved in reference cycle and they define _del_ (method such objects cannot be garbage-collected because in order to break the reference cyclethe interpreter must arbitrarily destroy lib fl ff