Request for Feedback: Memory Graph – A Python Visualization Tool for Education

Hi everyone,

I’ve been working on memory_graph, a Python package designed to visualize memory and variable states in Python programs. It’s an educational tool similar to Python Tutor but removes its restrictions on program complexity, external libraries, and I/O capabilities while enabling better integration into custom teaching environments.

Before creating a video tutorial, I’d love to hear your thoughts on its utility and any suggestions for improvement. If you have a moment to try it or share your perspective, I’d greatly appreciate it.

Thank you in advance for your feedback!

4 Likes

This looks awesome! I just spun it up to look at some data structures I regularly use.

One quick note is that if you’re exploring in a Jupyter notebook or similar, using mg.create_graph(...) will render inline instead of saving to file and opening an external program.

I would be interested also in potentially declaring a maximum depth to introspect types (with, e.g., 0 indicating that the type should be considered primitive). The specific example I have in mind is visualizing graphs where the deep structure of the nodes is less interesting than the top-level graph structure. I might want to go one level deep in Node to see where nodes are sharing objects, but not clutter the screen with many object trees.

1 Like

@Chris, I’m glad you like it.

Great note, I wasn’t aware of Jupyter Notebook inline rendering. I’ll definitely add that to the documentation. Inline rendering might then also be a solution in webassembly where I was having trouble, thanks.

Great suggestion about having an optional maximum introspection level for each type (or even ‘id’) to limit the size of the graph. I have been playing with ‘mg.config.max_tree_depth’ and Slicer to reduce the size of the graph (it quickly gets too big in non-educational software), but your suggestions gives much better control. I’ll see how we can implement it.

This looks so cool! I am excited to try this. The call stack introspection in particular stood out to me.

Compliments on your extensive documentation and examples. That alone must take lots and hard work.

Some years ago I helped teach undergraduate second semester programming. I think something like this would be very useful! And when I was a student myself I think I would have loved to have this for a course on more advanced data structures and algorithms.

1 Like

@flyinghyrax Thank you for your comments and perspective.

I agree memory_graph is helpful when learning data structures and algorithms, but I also hope it can be of value much earlier just after introducing lists as the first mutable type. I feel that with an intuitive visualization of concepts like mutability, shallow/deep copy, ‘call by object reference’ students can learn the Python Data Model with much less effort. Especially when using a debugger to show each execution step (this will have to feature in a video, it doesn’t come across well in the docs). The Python Data Model is fundamental to Python, yet it is sometimes overlooked in introductory courses potentially leading to ‘unsolvable’ bugs, I think because it is just hard to teach without the right tools.

This is my attempt to cover these concepts with memory_graph: Python Data Model

I would like to hear about your experience with memory_graph after you tried it, if you want to share.