@@ -269,9 +269,9 @@ You should know how to generate a trace by now. The trace again contains **four*
269269four execution steps (one for the very beginning of execution plus three executed lines).
270270
271271"Step 1 of 3" is boring since nothing is displayed. Let's jump to "Step 2 of 3"
272- ([ click here ] ( http://pythontutor.com/visualize.html#code=x+%3D+%5B1,+2,+3%5D%0Ay+%3D+('Alice',+'Bob',+'Cindy')%0Az+%3D+%7B'carrot'%3A+'vegetable',+'mouse'%3A+'animal',+'rock'%3A+'mineral'%7D%0A&mode=display&cumulative=false&py=2&curInstr=1 ) )
272+ (< a href = " http://pythontutor.com/visualize.html#code=x+%3D+%5B1,+2,+3%5D%0Ay+%3D+('Alice',+'Bob',+'Cindy')%0Az+%3D+%7B'carrot'%3A+'vegetable',+'mouse'%3A+'animal',+'rock'%3A+'mineral'%7D%0A&mode=display&cumulative=false&py=2&curInstr=1 " >click here</ a > )
273273
274- The visualization shows that ` x ` points to a list containing ` [1, 2, 3] ` . This is the corresponding execution
274+ The visualization now shows ` x ` pointing to a list containing ` [1, 2, 3] ` . This is the corresponding execution
275275point object:
276276
277277``` javascript
@@ -301,5 +301,78 @@ point object:
301301 }
302302```
303303
304+ Note that in ` globals ` , ` x ` now refers to a ` ["REF", 1] ` object, which means a * reference* (pointer) to a heap
305+ object with an ID of 1.
306+
307+ Let's now look at ` heap ` , which is a mapping of heap object IDs to their contents. The current heap has one
308+ object with an ID of 1. That object is a list of [ 1, 2, 3] , which is represented as:
309+
310+ ``` javascript
311+ [" LIST" , 1 , 2 , 3 ]
312+ ```
313+
314+ Let's skip forward to the end of execution ("Program terminated"):
315+ (<a href =" http://pythontutor.com/visualize.html#code=x+%3D+%5B1,+2,+3%5D%0Ay+%3D+('Alice',+'Bob',+'Cindy')%0Az+%3D+%7B'carrot'%3A+'vegetable',+'mouse'%3A+'animal',+'rock'%3A+'mineral'%7D%0A&mode=display&cumulative=false&py=2&curInstr=3 " >click here</a >)
316+
317+ Now there are three variables -- ` x ` points to a list, ` y ` points to a tuple, and ` z ` points to a dict.
318+ This execution point object is getting kinda big:
319+
320+ ``` javascript
321+ {
322+ " ordered_globals" : [
323+ " x" ,
324+ " y" ,
325+ " z"
326+ ],
327+ " stdout" : " " ,
328+ " func_name" : " <module>" ,
329+ " stack_to_render" : [],
330+ " globals" : {
331+ " y" : [
332+ " REF" ,
333+ 2
334+ ],
335+ " x" : [
336+ " REF" ,
337+ 1
338+ ],
339+ " z" : [
340+ " REF" ,
341+ 3
342+ ]
343+ },
344+ " heap" : {
345+ " 1" : [
346+ " LIST" ,
347+ 1 ,
348+ 2 ,
349+ 3
350+ ],
351+ " 2" : [
352+ " TUPLE" ,
353+ " Alice" ,
354+ " Bob" ,
355+ " Cindy"
356+ ],
357+ " 3" : [
358+ " DICT" ,
359+ [
360+ " carrot" ,
361+ " vegetable"
362+ ],
363+ [
364+ " mouse" ,
365+ " animal"
366+ ],
367+ [
368+ " rock" ,
369+ " mineral"
370+ ]
371+ ]
372+ },
373+ " line" : 3 ,
374+ " event" : " return"
375+ }
376+ ```
304377
305378## Function Stack Frames
0 commit comments