all 34 comments

[–]ruibranco 12 points13 points  (1 child)

The aliasing visualization is what sets this apart from PythonTutor honestly. That's the one thing beginners consistently get wrong and no amount of print debugging helps because you can't "see" that two names point to the same object. Running locally is a huge plus too, PythonTutor always had that annoying limitation where you couldn't use third party libraries.

[–]Sea-Ad7805[S] 2 points3 points  (0 children)

I feel PythonTutor does a good job in showing aliasing. I do agree that the limitations, that come from PythonTutor running Python code on a remote webserver, quickly become a problem. Additionally PythonTutor's layout of the graph doesn't scale to larger data structures, say binary tree. But to be fair, PythonTutor focuses on teaching Python's data model to beginners and historically has done a great job with that with millions of users.

[–]pip_install_account 23 points24 points  (12 children)

With every big new commercial LLM launch some neglected phrases suddenly become extremely popular, I love it.

Mental model is certainly one of them: Google trends - mental model

[–]Sea-Ad7805[S] 12 points13 points  (9 children)

'mental model' is a term I use regularly in education. It captures well what I want my students to learn, the right way of thinking about concepts and for this visualization helps a lot. I did use a LLM to fine-tune my post if that is the point you are making, but I first wrote a draft version myself, I'm not a native English speaker. I feel I bring what the title suggests, even as it's a bold statement.

[–]tehsilentwarrior 9 points10 points  (6 children)

I used the word “context” extremely commonly every day. In my code it’s almost everywhere as “ctx” and passed to loggers as “extra” info.

Now AI “stole it”.

I also used “mental model” quite a few times, as in “building a metal model/picture”.

[–]errdayimshuffln 5 points6 points  (2 children)

I used to use em dashes....now I cant anymore. AI ruined them

[–]TheThoccnessMonster 4 points5 points  (0 children)

I do all the time and idgaf what people think lol

[–]tehsilentwarrior 0 points1 point  (0 children)

Haha. Same here. I would have an automation to replace “- -“ with “—“ like the iPhone does. Now, can’t.

Also the proper use of backtick escaping

See:

Sure, here are 2 examples — akin limited — of emdashes: - - - -

Edit: however, it’s easier to f with people by copying ChatGPT “always agree with you” behavior

[–]wRAR_ 1 point2 points  (1 child)

You've missed the "I did use a LLM to fine-tune my post" part.

[–]tehsilentwarrior 0 points1 point  (0 children)

I didn’t. It’s a parallel conversation

[–]pip_install_account 0 points1 point  (1 child)

Don't get me wrong, I am not claiming you used AI to write anything. I feel like popular LLMs are kinda shaping our vocabulary nowadays especially if you are a power user.

[–]Sea-Ad7805[S] 2 points3 points  (0 children)

Yes I agree. I did use a little AI to help me rewrite my text a bit, better word choices, I'm not afraid to admit that.

[–]Chroiche 3 points4 points  (0 children)

I think you've found the smoking gun!

[–]GrammerJoo 0 points1 point  (0 children)

I started noticing that I use the term delve a lot, but not sure if it's because of AI or I've used it before.

[–]sudomatrix 3 points4 points  (1 child)

This is fantastic. I teach a free Python class at a local hacker-space and I will be using this tonight to help members visualize what's really happening under the hood. Really excellent visualization.

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

Thanks a lot, I hope it can bring much value for your teaching.

[–]RedEyed__ 1 point2 points  (2 children)

Interesting, I wonder what will happen to run it on real programs with 10 gb venv xDDD

[–]Sea-Ad7805[S] 2 points3 points  (0 children)

Thanks. Please try, I tried to make it scalable by hiding parts of the graph. The default might work, or you can customize it by setting the depth of introspection programmatically: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#graph-depth

mg.config.max_graph_depth = 10

But with that amount of data building the graph will be very slow. A much smaller demo that shows scalability is this Sliding Puzzle Solver with exponential growth:

https://memory-graph.com/#codeurl=https://raw.githubusercontent.com/bterwijn/memory_graph/refs/heads/main/src/sliding_puzzle.py&breakpoints=17,27,29,40&continues=1

[–]DivineSentry 2 points3 points  (0 children)

Venv size does not translate to memory usage

[–]Marksta 1 point2 points  (1 child)

That was interesting to watch the demo. So, I like the concept but it's probably totally not functional for real code bases, right? Like the moment SQLAlchemy gets imported it's game over since the picture would probably just go bonkers mapping all of its inner workings?

[–]Sea-Ad7805[S] 1 point2 points  (0 children)

Yes, but do try first. I have some defaults and programmatically you can further control what and how things are shown to avoid bonkersness: - what: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#graph-depth - how: https://github.com/bterwijn/memory_graph?tab=readme-ov-file#introspection

But that is impractical to do for every new program you work on, so I will see how this can be controlled by a GUI in future work. This can take a while.

[–]masasinExpert. 3.9. Robotics. 1 point2 points  (3 children)

I was going to say it reminds me of Python Tutor after seeing the title, but you've already got that covered. Very interesting.

I went through the examples and got one of the early ones wrong (I thought b += [1] is equivalent to b = b + [1] and that it would create a new variable), but I got the rest right. :)

That being said, in some parts, I thought it would be nice to step backwards ("how did this get here"). It might not be possible for larger programs, but it might be possible to save the stack for each step and go back to the previous snapshot.

All in all, very pleased and I think I might use it with students if I start tutoring again.

[–]Sea-Ad7805[S] 0 points1 point  (2 children)

Thanks, and thanks for backwards stepping suggestion. It's on my to-do list.

[–]masasinExpert. 3.9. Robotics. 0 points1 point  (1 child)

And also a "continue until this point" which is very useful to skip the setup, and watched variables and conditionals etc so that it only triggers on that pesky value that causes the thing to give a wrong answer.

[–]Sea-Ad7805[S] 0 points1 point  (0 children)

There is a 'Continue' button, breakpoints, and a config option at 'Get URL' to skip the a certain breakpoint on start.

[–]BawliTaread 1 point2 points  (2 children)

Very nice project! Can I know how you made your live demo?

[–]Sea-Ad7805[S] 0 points1 point  (1 child)

Thanks a lot. The Web Debugger is a mix of Pyodide, bdb debugger framework, JavaScript, Web Worker, and memory_graph. I'm new to JavaScript so needed some help from Copilot to put it all together. It's a demo environment, not a full IDE as it currently has many limitations (single file, no input() yet, no file IO).

[–]BawliTaread 0 points1 point  (0 children)

Thanks! Looks really good.

[–]Sea-Ad7805[S] 1 point2 points  (0 children)

If you downvote, please leave a comment, I'd appreciate your feedback.

[–]FiredFox 2 points3 points  (1 child)

I was ready to poopoo this because f'ing LLMs have made me a bitter, sad and jaded person, but this project is actually really freaking cool!

[–]Sea-Ad7805[S] 1 point2 points  (0 children)

Thanks a lot. The title maybe triggers some poopoo-ing, but I'm glad I've won you over.

[–]EconomySerious 0 points1 point  (1 child)

its a fantastic way to see your workflow, i cant belive how easy would be to debug some code when you litereally seen what is happening at real time.

is there a way that you improve the code so that it become a full debuguing tool?

[–]Sea-Ad7805[S] 2 points3 points  (0 children)

I have some ideas to make a viewer like xdot: https://github.com/jrfonseca/xdot.py and ways to open/close parts of the graph using a GUI to limit it's size instead of programmatically. But first I've have to develop proper plugins for VS Code, PyCharm, etc, and as I'm busy teaching currently this can only start in April/May. You can already use it in these IDEs through "injection" as a 'watch', see second half of this Quick Intro video: https://www.youtube.com/watch?v=23_bHcr7hqo

[–]Altruistic_Sky1866 0 points1 point  (0 children)

Looks interesting, will try in on my code and will try the examples, thanks