Shallow Copy vs. Deep Copy in Python

Understand how copying works in Python with helpful examples

Artturi Jalli
Better Programming
Published in
4 min readMay 27, 2021

--

Python logo with ship on the sea
Image by the author.

In Python, a shallow copy is a “one-level-deep” copy. The copied object contains references to the child objects of the original object.

A deep copy is completely independent of the original object. It constructs a new collection object by recursively populating it with…

--

--