Python visualization tool 'memory_graph'
#62 733 ouverte le 11 oct. 2025
Métriques du dépôt
- Stars
- (444 744 stars)
- Métriques de merge PR
- (Merge moyen 6j 11h) (253 PRs mergées en 30 j)
Description
Hello,
Quincy Larson asked me to add an issue with suggestions about how the visualizations of the 'memory_graph' Python package (https://github.com/bterwijn/memory_graph) could maybe be used for Python education in the freecodecamp environment:
-
explain that function parameters are new variables (that might have the same name) that exist until the function returns (scope) https://memory-graph.com/#code=%0Adef%20function_with_parameters(a%2C%20b)%3A%0A%20%20%20%20a%20%3D%20a%20%2B%20b%0A%20%20%20%20return%20a%0A%0Aa%20%3D%2010%0Ab%20%3D%205%0Ac%20%3D%20function_with_parameters(a%2C%20b)%0Aprint('c%3A'%2C%20c)%0A&play
-
explain that a variable is a reference to a value, assigning one variable to another makes them share the value, if the value is mutable then changing one variable changes the other https://memory-graph.com/#code=%0Aa%20%3D%20%5B4%2C%203%2C%202%5D%0Ab%20%3D%20a%0Ab.append(1)%20%20%23%20changes%20both%20'b'%20and%20'a'%0A%0A&play
-
explain various data structures, this is a Binary Tree example: https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/bin_tree.py×tep=0.2&play
-
Linked List data structure: https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/linked_list.py×tep=0.2&play
As the call_stack is visualized in an intuitive way (there is a slight learning curve of course) it becomes easy to understand the complete program state at any time during execution, even for beginners. The Python Data Model (references, mutability, shallow vs deep copy) is often skipped because it is hard to explain without visualization, but is fundamental to Python (in the sense that not understanding will result in many bugs). With the help of memory_graph visualizations it can be explained with relative ease.
You find some challenging quiz questions here: https://github.com/bterwijn/memory_graph_videos/blob/main/exercises/exercises.md At the end of this video you find a nice example of a programming exercise: https://www.youtube.com/watch?v=pvIJgHCaXhU&t=892s
The memory_graph package is open source and free to download: https://github.com/bterwijn/memory_graph If you see value then feel free to use it in the freecodecamp environment. Contact me in case of questions/discussion/feedback, maybe on LinkedIn: https://www.linkedin.com/in/bas-terwijn-b0a9b18/
Best regards, Bas Terwijn