6
submitted 1 month ago* (last edited 1 month ago) by bterwijn@programming.dev to c/python@programming.dev

Data structures like Trie can in Python be easier understood and debugged after visualization using the memory_graph package.

A Trie is a tree of dictionaries and can be used for things like word completion.

[-] bterwijn@programming.dev 2 points 2 months ago

Nice one, see the "Solution" link for correct answer.

[-] bterwijn@programming.dev 5 points 2 months ago

Yes I understand your point, but I'm trying to reach out so people are aware and can use it in Python education. I feel it can really help beginners understand tricky concepts with ease, bit it's hard to reach a bigger audience these days. Sorry for the repetition, I'll guess I should cut back a bit.

14

Data structures become much easier to understand when students can see the structure of their data visualized using memory_graph. A data structure is no longer an abstract idea but concrete, clear and debuggable. Here’s a live demo of a Linear Linked List: https://memory-graph.com/#codeurl=https%3A%2F%2Fraw.githubusercontent.com%2Fbterwijn%2Fmemory_graph%2Frefs%2Fheads%2Fmain%2Fsrc%2Flinked_list_lin.py&breakpoints=27&continues=1&timestep=0.2&play=

[-] bterwijn@programming.dev 2 points 2 months ago

Incorrect sorry, check the "Solution" link for the correct answer.

14
submitted 2 months ago* (last edited 2 months ago) by bterwijn@programming.dev to c/python@programming.dev

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:

18

Understanding and debugging Python data structures gets easier with memory_graph visualization. Here's a Multiway Tree example. A Multiway Tree is similar to a Binary Tree but has an arbitrary number of children making the tree less deep and more efficient.

14
Python Copies (thelemmy.club)

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:

[-] bterwijn@programming.dev 3 points 3 months ago

__add__ is called with + and __iadd__ is called with +=, and there is a difference: https://www.reddit.com/r/PythonLearning/comments/1nw08wu/right_mental_model_for_python_data/

21
Python Mutability (thelemmy.club)

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:

5
submitted 3 months ago* (last edited 3 months ago) by bterwijn@programming.dev to c/python@programming.dev

Teaching and learning Python bitwise operators gets much easier after showing the binary representations of integers using memory_graph: bitwise operators in Memory Graph Web Debugger

Understanding of the inverse ~ operator is helped by showing the two’s complement representation.

14

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:

14

Some struggle with recursion, but as package invocation_tree visualizes the Python call tree in real time, it gets easy to understand what is going on and to debug any remaining issues.

See this one-click Quick Sort demo in the Invocation Tree Web Debugger.

19

Better understand the Python Data Model or Data Structures by memory_graph visualization with just one click:

[-] bterwijn@programming.dev 2 points 5 months ago* (last edited 5 months ago)

Actually running the code? I got to the stage where only AI can help me understand anything ;-)

[-] bterwijn@programming.dev 2 points 5 months ago* (last edited 5 months ago)

Thanks for your feedback, much appriciated.

I agree that an exercise14.rst would be nice, but to save time I've let the code speak for itself now together with the visualizaion. I'll probably revisit and better document the exercises later.

At the Explanation link I try to give a general explanation about Pyrhon mutability (and copy later on), I agree some readers might find it hard to relate that to a specific exercise, but I don't want to write a specific explanation for each exercise.

[-] bterwijn@programming.dev 2 points 5 months ago* (last edited 5 months ago)

Thanks for reporting, should be fixed now.

[-] bterwijn@programming.dev 2 points 5 months ago
[-] bterwijn@programming.dev 4 points 5 months ago* (last edited 5 months ago)

The "Solution" link gives the solution to the exercise, the "Explanation" link explains the Python data model concepts behind the exercise. If some parts are hard to understand let me know.

[-] bterwijn@programming.dev 3 points 5 months ago

Yes, that is a surprise to many, in other languages 'x+=y' and 'x=x+y' are the same.

[-] bterwijn@programming.dev 3 points 5 months ago

Thanks, glad it helps you.

53
Python Mutability (programming.dev)

See the Solution and Explanation.

[-] bterwijn@programming.dev 2 points 5 months ago* (last edited 5 months ago)

Glad you like it. Sketching by hand should remain standard practice, but for beginners that might be difficult. First they need to learn the right mental model to think about Python data, and I hope memory_graph can help with that.

33
Memory Graph Web Debugger (programming.dev)
submitted 5 months ago* (last edited 5 months ago) by bterwijn@programming.dev to c/python@programming.dev

Hi, I'm new, I'd like to share my new Memory Graph Web Debugger that you can use to visualize and debug your Python data structures with just one click. This is an example of a binary tree implementation. I feel this tool could level up Python education. I'm interested in your thoughts about it, feedback welcome.

view more: next ›

bterwijn

0 post score
0 comment score
joined 5 months ago