Problem Situation
- I was trying to make a copy of the original document using a deep copy to create test code, but after importing the copy module and proudly using the copy() method, I ended up struggling with why it wasn’t making a deep copy. -> Solution: Import the copy module as before, but use deepcopy from the copy module to solve the problem.
Shallow Copy vs. Deep Copy
- Since there are many ways to make a shallow copy, I will explain deep copying first.
Deep Copy
Method
- copy.deepcopy(data)
Principle
- Assign the original to a different memory location

Shallow Copy
Methods
- Assignment (=)
- [:] slicing
- object.copy
- copy.copy
Principle
-
Assignment (=): A method in which another copy variable points to the same memory address where the original’s information is stored (the address values are the same)

-
Slicing, object.copy, copy.copy:

References: https://blockdmask.tistory.com/576