You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b046cd5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: v3/docs/opt-trace-format.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -184,6 +184,8 @@ which was the code `x = 5`. If you look at the
184
184
[visualization at this step](http://pythontutor.com/visualize.html#code=x+%3D+5%0Ay+%3D+10%0Az+%3D+x+%2B+y&mode=display&cumulative=false&py=2&curInstr=1),
185
185
you'll see that `x` has been assigned to `5`.
186
186
187
+
Ok let's keep marching to the next execution point, which is the one that corresponds to "Step 3 of 3"
188
+
in the frontend:
187
189
188
190
```javascript
189
191
{
@@ -204,6 +206,20 @@ you'll see that `x` has been assigned to `5`.
204
206
}
205
207
```
206
208
209
+
Now `line` is 3, because we're about to execute line 3 (we just executed lines 1 and 2). Notice that there is a
210
+
new key-value pair in`globals` showing that `y` has been assigned to `10`. No surprises here, since we just
211
+
executed the line `y = 10`.
212
+
213
+
Ok now this is where I want to talk about `ordered_globals`, which is a list of global variables (i.e.,
214
+
keys in `globals`) in the order that the frontend should visualize them. The backend appends variable
215
+
names in their order of appearance throughout execution. Why is this list necessary? Because `globals`
216
+
is an object whose keys are unsorted, so if you don't also keep an `ordered_globals` sorted list,
217
+
then the visualization might end up being jarring. For instance, at one execution point, it might
218
+
render `x` and then `y`, and at the next execution point, it might render `y` and then `x`, thereby
219
+
causing the visualization to "jitter" unnecessarily. And I've found that it looks aesthetically pleasing
220
+
when variables are sorted in their order of appearance as you step forwards through execution.
0 commit comments