How to Leak State With copy Versus deepcopy
copy.copy keeps nested references. Change one dict and every copy changes. Production data corruption in one line.

How to Leak State With copy Versus deepcopy
copy.copy keeps nested references. Change one dict and every copy changes. Production data corruption in one line.

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:
- Solution: https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph_videos/refs/heads/main/exercises/exercise10.py&breakpoints=13&continues=1&play
- Explanation: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#python-data-model
If you think this could help Python students and educators, please boost.