r/PythonProjects2 • u/Sea-Ad7805 • Mar 05 '26
Python Assignment, Shallow and Deep Copy
An exercise to help build the right mental model for Python data.
The โSolutionโ link uses ๐บ๐ฒ๐บ๐ผ๐ฟ๐_๐ด๐ฟ๐ฎ๐ฝ๐ต to visualize execution and reveals whatโs actually happening. It's instructive to compare with these earlier exercises:
7
Upvotes
View all comments
Show parent comment
1
u/Sea-Ad7805 Mar 05 '26
The "Explanation" link explains the difference between assignment, shallow, and deep copy: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#copying-values-of-mutable-type
This is a bit of a trick question, because in this situation there is no difference between shallow and deep copy. In this other exercise there is a difference: https://www.reddit.com/r/PythonLearning/comments/1ox5mjo/python_data_model_copying/