Python Tutor – Visualize Code Execution, Memory & Variables
Understanding Program Execution with Python Tutor
What happens during line-by-line execution?
As a program runs, each statement updates variables and control flow in sequence. Local variables and active function calls live inside stack frames, while lists, dictionaries, objects, and arrays are stored in heap memory.
What are Stack Frames?
A stack frame (activation record) is pushed onto the call stack whenever a function runs. It holds that call's parameters and local variables, then pops off the stack as soon as the function returns.
How does Object Aliasing work?
In Python and JavaScript, assigning an existing list or object to another variable (such as b = a) does not duplicate the data. Both variables hold references pointing to the exact same object on the heap.
Why visualize Pointer Arrows?
Pointer arrows connect stack variables directly to their heap objects, making mutability, recursion, linked lists, and shared references much easier to debug and learn.