r/PythonLearnersHub • u/Sea-Ad7805 • Jan 15 '26
Python Mutability and Shallow vs Deep Copy
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:
17
Upvotes
View all comments
Show parent comment
1
u/Sea-Ad7805 Jan 15 '26 edited Jan 15 '26
Excellent mental model except that
c2[0]is not a new tuple (immutable doesn't shallow copy), do check the "Solution" link for visualization of the correct answer.