-
Notifications
You must be signed in to change notification settings - Fork 96
/
lec-21.html
65 lines (44 loc) · 27.6 KB
/
lec-21.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
Python Tutor: https://github.com/pgbovine/OnlinePythonTutor/
Copyright (C) Philip Guo (philip@pgbovine.net)
LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
-->
<head>
<title>CS 301 - References</title>
<script type="text/javascript" src="../js/pytutor-embed.bundle.js" charset="utf-8"></script>
</head>
<body style="background-color: white;">
<h1>Example 1: reassign parameter</h1>
<div id="lec-21_p1_py"></div>
<script type="text/javascript">
var trace = {"code": "def f(x):\n x *= 3\n print(\"f:\", x)\n\nnum = 10\nf(num)\nprint(\"after:\", num)", "trace": [{"line": 1, "event": "step_line", "func_name": "<module>", "globals": {}, "ordered_globals": [], "stack_to_render": [], "heap": {}, "stdout": ""}, {"line": 5, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1]}, "ordered_globals": ["f"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": ""}, {"line": 6, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": ""}, {"line": 1, "event": "call", "func_name": "f", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"x": 10}, "ordered_varnames": ["x"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": ""}, {"line": 2, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"x": 10}, "ordered_varnames": ["x"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": ""}, {"line": 3, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"x": 30}, "ordered_varnames": ["x"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": ""}, {"line": 3, "event": "return", "func_name": "f", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"x": 30, "__return__": null}, "ordered_varnames": ["x", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": "f: 30\n"}, {"line": 7, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": "f: 30\n"}, {"line": 7, "event": "return", "func_name": "<module>", "globals": {"f": ["REF", 1], "num": 10}, "ordered_globals": ["f", "num"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(x)", null]}, "stdout": "f: 30\nafter: 10\n"}]};
addVisualizerToPage(trace, 'lec-21_p1_py', {startingInstruction: 0, hideCode: false, lang: "py3"});
</script>
<h1>Example 2: modify list via parameter</h1>
<div id="lec-21_p2_py"></div>
<script type="text/javascript">
var trace = {"code": "def f(items):\n items.append(\"!!!\")\n print(\"f:\", items)\n\nwords = ['hello', 'world']\nf(words)\nprint(\"after:\", words)\n", "trace": [{"line": 1, "event": "step_line", "func_name": "<module>", "globals": {}, "ordered_globals": [], "stack_to_render": [], "heap": {}, "stdout": ""}, {"line": 5, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1]}, "ordered_globals": ["f"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 6, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": ""}, {"line": 1, "event": "call", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world"], "1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 2, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world"], "1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 3, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world", "!!!"], "1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 3, "event": "return", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2], "__return__": null}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world", "!!!"], "1": ["FUNCTION", "f(items)", null]}, "stdout": "f: ['hello', 'world', '!!!']\n"}, {"line": 7, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world", "!!!"]}, "stdout": "f: ['hello', 'world', '!!!']\n"}, {"line": 7, "event": "return", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world", "!!!"]}, "stdout": "f: ['hello', 'world', '!!!']\nafter: ['hello', 'world', '!!!']\n"}]};
addVisualizerToPage(trace, 'lec-21_p2_py', {startingInstruction: 0, hideCode: false, lang: "py3"});
</script>
<h1>Example 3: reassign new list to parameter</h1>
<div id="lec-21_p3_py"></div>
<script type="text/javascript">
var trace = {"code": "def f(items):\n items = items + [\"!!!\"]\n print(\"f:\", items)\n\nwords = ['hello', 'world']\nf(words)\nprint(\"after:\", words)", "trace": [{"line": 1, "event": "step_line", "func_name": "<module>", "globals": {}, "ordered_globals": [], "stack_to_render": [], "heap": {}, "stdout": ""}, {"line": 5, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1]}, "ordered_globals": ["f"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 6, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": ""}, {"line": 1, "event": "call", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world"], "1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 2, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 2]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"2": ["LIST", "hello", "world"], "1": ["FUNCTION", "f(items)", null]}, "stdout": ""}, {"line": 3, "event": "step_line", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"3": ["LIST", "hello", "world", "!!!"], "1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": ""}, {"line": 3, "event": "return", "func_name": "f", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [{"func_name": "f", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": null}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "f_f1"}], "heap": {"3": ["LIST", "hello", "world", "!!!"], "1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": "f: ['hello', 'world', '!!!']\n"}, {"line": 7, "event": "step_line", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": "f: ['hello', 'world', '!!!']\n"}, {"line": 7, "event": "return", "func_name": "<module>", "globals": {"f": ["REF", 1], "words": ["REF", 2]}, "ordered_globals": ["f", "words"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "f(items)", null], "2": ["LIST", "hello", "world"]}, "stdout": "f: ['hello', 'world', '!!!']\nafter: ['hello', 'world']\n"}]};
addVisualizerToPage(trace, 'lec-21_p3_py', {startingInstruction: 0, hideCode: false, lang: "py3"});
</script>
<h1>Example 4: in-place sort</h1>
<div id="lec-21_p4_py"></div>
<script type="text/javascript">
var trace = {"code": "def first(items):\n return items[0]\n\ndef smallest(items):\n items.sort()\n return items[0]\n\nnumbers\t= [4,5,3,2,1]\nprint(\"first:\", first(numbers))\nprint(\"smallest:\", smallest(numbers))\nprint(\"first:\", first(numbers))", "trace": [{"line": 1, "event": "step_line", "func_name": "<module>", "globals": {}, "ordered_globals": [], "stack_to_render": [], "heap": {}, "stdout": ""}, {"line": 4, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1]}, "ordered_globals": ["first"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null]}, "stdout": ""}, {"line": 8, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2]}, "ordered_globals": ["first", "smallest"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 9, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": ""}, {"line": 1, "event": "call", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 2, "event": "step_line", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 2, "event": "return", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": 4}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 10, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\n"}, {"line": 4, "event": "call", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 5, "event": "step_line", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 6, "event": "step_line", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 6, "event": "return", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": 1}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 11, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 1, 2, 3, 4, 5]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 1, "event": "call", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 2, "event": "step_line", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 2, "event": "return", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": 1}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 11, "event": "return", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 1, 2, 3, 4, 5]}, "stdout": "first: 4\nsmallest: 1\nfirst: 1\n"}]};
addVisualizerToPage(trace, 'lec-21_p4_py', {startingInstruction: 0, hideCode: false, lang: "py3"});
</script>
<h1>Example 5: sorted sort</h1>
<div id="lec-21_p5_py"></div>
<script type="text/javascript">
var trace = {"code": "def first(items):\n return items[0]\n\ndef smallest(items):\n items = sorted(items)\n return items[0]\n\nnumbers\t= [4,5,3,2,1]\nprint(\"first:\", first(numbers))\nprint(\"smallest:\", smallest(numbers))\nprint(\"first:\", first(numbers))", "trace": [{"line": 1, "event": "step_line", "func_name": "<module>", "globals": {}, "ordered_globals": [], "stack_to_render": [], "heap": {}, "stdout": ""}, {"line": 4, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1]}, "ordered_globals": ["first"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null]}, "stdout": ""}, {"line": 8, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2]}, "ordered_globals": ["first", "smallest"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 9, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": ""}, {"line": 1, "event": "call", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 2, "event": "step_line", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 2, "event": "return", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 1, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": 4}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f1"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": ""}, {"line": 10, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\n"}, {"line": 4, "event": "call", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 5, "event": "step_line", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\n"}, {"line": 6, "event": "step_line", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 4]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"4": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\n"}, {"line": 6, "event": "return", "func_name": "smallest", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "smallest", "is_parent": false, "frame_id": 2, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 4], "__return__": 1}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "smallest_f2"}], "heap": {"4": ["LIST", 1, 2, 3, 4, 5], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\n"}, {"line": 11, "event": "step_line", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 1, "event": "call", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 2, "event": "step_line", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3]}, "ordered_varnames": ["items"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 2, "event": "return", "func_name": "first", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [{"func_name": "first", "is_parent": false, "frame_id": 3, "parent_frame_id_list": [], "encoded_locals": {"items": ["REF", 3], "__return__": 4}, "ordered_varnames": ["items", "__return__"], "is_zombie": false, "is_highlighted": true, "unique_hash": "first_f3"}], "heap": {"3": ["LIST", 4, 5, 3, 2, 1], "1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null]}, "stdout": "first: 4\nsmallest: 1\n"}, {"line": 11, "event": "return", "func_name": "<module>", "globals": {"first": ["REF", 1], "smallest": ["REF", 2], "numbers": ["REF", 3]}, "ordered_globals": ["first", "smallest", "numbers"], "stack_to_render": [], "heap": {"1": ["FUNCTION", "first(items)", null], "2": ["FUNCTION", "smallest(items)", null], "3": ["LIST", 4, 5, 3, 2, 1]}, "stdout": "first: 4\nsmallest: 1\nfirst: 4\n"}]};
addVisualizerToPage(trace, 'lec-21_p5_py', {startingInstruction: 0, hideCode: false, lang: "py3"});
</script>
</body>
</html>