copy
Stdlib — DataPython 2.0+Beginner
Shallow and deep copy operations for objects
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
- Dependencies
- None — Python Standard Library
- Install
Included with Python
Learn by Difficulty
Quick Example
python
import copy # Shallow vs deep copy original = [[1, 2], [3, 4]] shallow = copy.copy(original) deep = copy.deepcopy(original) original[0].append(99) print(f"Original: {original}") print(f"Shallow: {shallow}") # Affected! print(f"Deep: {deep}") # Not affected
The copy module is part of Python's standard library. Shallow and deep copy operations for objects.
Try in PlaygroundTags
stdlibdata-structure