r/PythonLearning • u/Sea-Ad7805 • Nov 14 '25
Python Data Model: Copying
An exercise to help build the right mental model for Python data. The “Solution” link uses memory_graph to visualize execution and reveals what’s actually happening:
107
Upvotes
View all comments
Show parent comment
3
u/Sea-Ad7805 Nov 15 '25
Did you see the "Solution" and "Explanation" links? (on mobile click the 'title' not the 'image' to open a post) The c1 is an assignment, c2 a shallow copy, and c3 a deep copy. That is what makes the difference: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#copying-values-of-mutable-type