Shallow Copy vs Deep Copy
Compare shallow copy and deep copy in this lesson.
We'll cover the following
In this section, we’ll learn how to copy the objects in Python. You must have heard the terms shallow copy and deep copy before.
Alert: Just a heads up that for primitive types (int), there’s no difference between a shallow copy and a deep copy.
Python’s built-in mutable objects can be copied by using their constructor. For example:
l2 = list(l1) # List l1 copied with list()
d2 = dict(d1) # Dictionary d2 copied with dict()
s2 = set(s1) # Set s2 copied with set()
Shallow copy
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy