What is the difference between shallow copy and deep copy?
Answer
•Shallow copy copies only the top level of the container.
•Nested objects remain shared.
•Deep copy recursively copies everything.
•Shallow: list.copy(), copy.copy().
•Deep: copy.deepcopy() (can be expensive).
Was this answer helpful?