memory-graph 0.3.57__tar.gz → 0.3.59__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {memory_graph-0.3.57/memory_graph.egg-info → memory_graph-0.3.59}/PKG-INFO +7 -4
- {memory_graph-0.3.57 → memory_graph-0.3.59}/README.md +6 -3
- memory_graph-0.3.59/images/add_one.png +0 -0
- memory_graph-0.3.59/images/avltree_key_value.png +0 -0
- memory_graph-0.3.59/images/avltree_leaf.png +0 -0
- memory_graph-0.3.59/images/avltree_linear.png +0 -0
- memory_graph-0.3.59/images/avltree_table.png +0 -0
- memory_graph-0.3.59/images/bin_search.png +0 -0
- memory_graph-0.3.59/images/bin_search_linear.png +0 -0
- memory_graph-0.3.59/images/bin_tree.png +0 -0
- memory_graph-0.3.59/images/binary.gif +0 -0
- memory_graph-0.3.59/images/copy_immutable.png +0 -0
- memory_graph-0.3.59/images/copy_method.png +0 -0
- memory_graph-0.3.59/images/copy_mix.png +0 -0
- memory_graph-0.3.59/images/copy_mutable.png +0 -0
- memory_graph-0.3.59/images/debugging.gif +0 -0
- memory_graph-0.3.59/images/embedded1.png +0 -0
- memory_graph-0.3.59/images/embedded2.png +0 -0
- memory_graph-0.3.59/images/extension_numpy.png +0 -0
- memory_graph-0.3.59/images/extension_pandas.png +0 -0
- memory_graph-0.3.59/images/factorial.gif +0 -0
- memory_graph-0.3.59/images/hash_set.png +0 -0
- memory_graph-0.3.59/images/hidden_edges.png +0 -0
- memory_graph-0.3.59/images/immutable1.png +0 -0
- memory_graph-0.3.59/images/immutable2.png +0 -0
- memory_graph-0.3.59/images/introspect_depth.png +0 -0
- memory_graph-0.3.59/images/linked_list.png +0 -0
- memory_graph-0.3.59/images/many_types.png +0 -0
- memory_graph-0.3.59/images/mutable1.png +0 -0
- memory_graph-0.3.59/images/mutable2.png +0 -0
- memory_graph-0.3.59/images/power_set.gif +0 -0
- memory_graph-0.3.59/images/rebinding1.png +0 -0
- memory_graph-0.3.59/images/rebinding2.png +0 -0
- memory_graph-0.3.59/images/wrap_int.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/__init__.py +1 -1
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/config.py +2 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/config_default.py +5 -2
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/memory_to_nodes.py +10 -6
- {memory_graph-0.3.57 → memory_graph-0.3.59/memory_graph.egg-info}/PKG-INFO +7 -4
- {memory_graph-0.3.57 → memory_graph-0.3.59}/pyproject.toml +1 -1
- memory_graph-0.3.57/images/add_one.png +0 -0
- memory_graph-0.3.57/images/avltree_key_value.png +0 -0
- memory_graph-0.3.57/images/avltree_leaf.png +0 -0
- memory_graph-0.3.57/images/avltree_linear.png +0 -0
- memory_graph-0.3.57/images/avltree_table.png +0 -0
- memory_graph-0.3.57/images/bin_search.png +0 -0
- memory_graph-0.3.57/images/bin_search_linear.png +0 -0
- memory_graph-0.3.57/images/bin_tree.png +0 -0
- memory_graph-0.3.57/images/binary.gif +0 -0
- memory_graph-0.3.57/images/copy_immutable.png +0 -0
- memory_graph-0.3.57/images/copy_method.png +0 -0
- memory_graph-0.3.57/images/copy_mix.png +0 -0
- memory_graph-0.3.57/images/copy_mutable.png +0 -0
- memory_graph-0.3.57/images/debugging.gif +0 -0
- memory_graph-0.3.57/images/embedded1.png +0 -0
- memory_graph-0.3.57/images/embedded2.png +0 -0
- memory_graph-0.3.57/images/extension_numpy.png +0 -0
- memory_graph-0.3.57/images/extension_pandas.png +0 -0
- memory_graph-0.3.57/images/factorial.gif +0 -0
- memory_graph-0.3.57/images/hash_set.png +0 -0
- memory_graph-0.3.57/images/hidden_edges.png +0 -0
- memory_graph-0.3.57/images/immutable1.png +0 -0
- memory_graph-0.3.57/images/immutable2.png +0 -0
- memory_graph-0.3.57/images/introspect_depth.png +0 -0
- memory_graph-0.3.57/images/linked_list.png +0 -0
- memory_graph-0.3.57/images/many_types.png +0 -0
- memory_graph-0.3.57/images/mutable1.png +0 -0
- memory_graph-0.3.57/images/mutable2.png +0 -0
- memory_graph-0.3.57/images/power_set.gif +0 -0
- memory_graph-0.3.57/images/rebinding1.png +0 -0
- memory_graph-0.3.57/images/rebinding2.png +0 -0
- memory_graph-0.3.57/images/wrap_int.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/LICENSE.txt +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/MANIFEST.in +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/add_one.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/avltree.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/avltree_dir.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/avltree_fail.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/bin_search.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/bin_tree.gif +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/bin_tree.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/binary.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/colab_example.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/copy_immutable.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/copy_method.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/copy_mix.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/copy_mutable.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/create_gif.sh +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/create_images.sh +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/debug_vscode.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/debugging.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/extension_numpy.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/extension_pandas.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/extension_torch.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/extension_torch.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/factorial.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/hash_set.gif +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/hash_set.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/hidden_edges.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/immutable.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/introspect_depth.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/ipython.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/jupyter_example.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/linked_list.gif +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/linked_list.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/many_types.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/marimo_example.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/memory_graph_web_debugger.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/mutable.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/name_rebinding.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/not_node_types.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/power_set.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/uva.png +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/vscode_copying.gif +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/images/wrap_int.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/call_stack.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/config_helpers.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/extension_numpy.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/extension_pandas.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/extension_torch.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/html_table.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/list_view.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/node_base.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/node_key_value.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/node_leaf.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/node_linear.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/node_table.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/sequence.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/slicer.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/slices.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/slices_iterator.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/slices_table_iterator.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_max_graph_depth.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_memory_graph.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_memory_to_nodes.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_sequence.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_slicer.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_slices.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/test_slices_iterator.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph/utils.py +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph.egg-info/SOURCES.txt +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph.egg-info/dependency_links.txt +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph.egg-info/requires.txt +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/memory_graph.egg-info/top_level.txt +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/setup.cfg +0 -0
- {memory_graph-0.3.57 → memory_graph-0.3.59}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.59
|
|
4
4
|
Summary: Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy.
|
|
5
5
|
Author-email: Bas Terwijn <bterwijn@gmail.com>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -169,7 +169,7 @@ Learn the right **mental model** to think about Python data. The [Python Data Mo
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
## Immutable Type ##
|
|
172
|
-
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` reference their own value afterwards.
|
|
172
|
+
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` each reference their own value afterwards.
|
|
173
173
|
|
|
174
174
|
```python
|
|
175
175
|
import memory_graph as mg
|
|
@@ -203,7 +203,7 @@ mg.render(locals(), 'mutable2.png')
|
|
|
203
203
|
|:-----------------------------------------------------------:|:-------------------------------------------------------------:|
|
|
204
204
|
| mutable1.png | mutable2.png |
|
|
205
205
|
|
|
206
|
-
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it.
|
|
206
|
+
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it. Values of immutable type generally don't need to change as much, or are small, making copying less of a concern.
|
|
207
207
|
|
|
208
208
|
## Copying Values of Mutable Type ##
|
|
209
209
|
Python offers three different "copy" options that we will demonstrate using a nested list:
|
|
@@ -666,6 +666,9 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
666
666
|
- ***mg.config.render_filename*** : str
|
|
667
667
|
- The default filename to render to, default 'memory_graph.pdf'.
|
|
668
668
|
|
|
669
|
+
- ***mg.config.type_labels*** : bool
|
|
670
|
+
- If True the type of each node is shown as label, default True.
|
|
671
|
+
|
|
669
672
|
- ***mg.config.block_prints_location*** : bool
|
|
670
673
|
- If True the source location is printed in block(), default True.
|
|
671
674
|
|
|
@@ -712,7 +715,7 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
712
715
|
- Maximum number of missing edges that are shown with default value 2. Dashed references are used to indicate that there are more references to a node than are shown.
|
|
713
716
|
|
|
714
717
|
- ***mg.config.fontname*** : str
|
|
715
|
-
- The font used in the graph, default '
|
|
718
|
+
- The font used in the graph, default 'Times-Roman' (widely available on the web).
|
|
716
719
|
|
|
717
720
|
- ***mg.config.fontsize*** : str
|
|
718
721
|
- The font size used in the graph, default '14'.
|
|
@@ -149,7 +149,7 @@ Learn the right **mental model** to think about Python data. The [Python Data Mo
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
## Immutable Type ##
|
|
152
|
-
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` reference their own value afterwards.
|
|
152
|
+
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` each reference their own value afterwards.
|
|
153
153
|
|
|
154
154
|
```python
|
|
155
155
|
import memory_graph as mg
|
|
@@ -183,7 +183,7 @@ mg.render(locals(), 'mutable2.png')
|
|
|
183
183
|
|:-----------------------------------------------------------:|:-------------------------------------------------------------:|
|
|
184
184
|
| mutable1.png | mutable2.png |
|
|
185
185
|
|
|
186
|
-
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it.
|
|
186
|
+
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it. Values of immutable type generally don't need to change as much, or are small, making copying less of a concern.
|
|
187
187
|
|
|
188
188
|
## Copying Values of Mutable Type ##
|
|
189
189
|
Python offers three different "copy" options that we will demonstrate using a nested list:
|
|
@@ -646,6 +646,9 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
646
646
|
- ***mg.config.render_filename*** : str
|
|
647
647
|
- The default filename to render to, default 'memory_graph.pdf'.
|
|
648
648
|
|
|
649
|
+
- ***mg.config.type_labels*** : bool
|
|
650
|
+
- If True the type of each node is shown as label, default True.
|
|
651
|
+
|
|
649
652
|
- ***mg.config.block_prints_location*** : bool
|
|
650
653
|
- If True the source location is printed in block(), default True.
|
|
651
654
|
|
|
@@ -692,7 +695,7 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
692
695
|
- Maximum number of missing edges that are shown with default value 2. Dashed references are used to indicate that there are more references to a node than are shown.
|
|
693
696
|
|
|
694
697
|
- ***mg.config.fontname*** : str
|
|
695
|
-
- The font used in the graph, default '
|
|
698
|
+
- The font used in the graph, default 'Times-Roman' (widely available on the web).
|
|
696
699
|
|
|
697
700
|
- ***mg.config.fontsize*** : str
|
|
698
701
|
- The font size used in the graph, default '14'.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -23,7 +23,10 @@ def reset():
|
|
|
23
23
|
|
|
24
24
|
""" The default filename to render to. """
|
|
25
25
|
config.render_filename = 'memory_graph.pdf'
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
""" Show the type of each node as label. """
|
|
28
|
+
config.type_labels = True
|
|
29
|
+
|
|
27
30
|
""" Determines if the filename, line number and functions name is printed on mg.block(). """
|
|
28
31
|
config.block_prints_location = True
|
|
29
32
|
|
|
@@ -130,7 +133,7 @@ def reset():
|
|
|
130
133
|
config.max_missing_edges = 2
|
|
131
134
|
|
|
132
135
|
""" Font name and size used in the graph. """
|
|
133
|
-
config.fontname = '
|
|
136
|
+
config.fontname = 'Times-Roman'
|
|
134
137
|
config.fontsize = '14'
|
|
135
138
|
|
|
136
139
|
reset()
|
|
@@ -210,16 +210,20 @@ def build_graph(graphviz_graph, nodes, root_id, id_to_slices):
|
|
|
210
210
|
if len(new_node_names) > 1:
|
|
211
211
|
graphviz_graph.body.append('subgraph { rank=same; '+ ' -> '.join(new_node_names) + '[weight='+str(config.graph_stability)+', style=invis]; }\n')
|
|
212
212
|
|
|
213
|
-
def add_to_graphviz_graph(graphviz_graph, nodes, node, slices, id_to_slices
|
|
213
|
+
def add_to_graphviz_graph(graphviz_graph, nodes, node, slices, id_to_slices):
|
|
214
214
|
""" Adds 'node' to 'graphviz_graph' with its children and edges. """
|
|
215
215
|
html_table = node.get_html_table(nodes, slices, id_to_slices)
|
|
216
216
|
edges = html_table.get_edges()
|
|
217
217
|
color = config_helpers.get_color(node)
|
|
218
218
|
border = 3 if node.is_root() else 1
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
if config.type_labels:
|
|
220
|
+
graphviz_graph.node(node.get_name(),
|
|
221
|
+
html_table.to_string(border, color),
|
|
222
|
+
xlabel=node.get_label(slices))
|
|
223
|
+
else:
|
|
224
|
+
graphviz_graph.node(node.get_name(),
|
|
225
|
+
html_table.to_string(border, color))
|
|
226
|
+
# ------------ edges
|
|
223
227
|
for parent,child,dashed in edges:
|
|
224
228
|
graphviz_graph.edge(parent, child+':table', style='dashed' if dashed else 'solid')
|
|
225
229
|
|
|
@@ -239,7 +243,7 @@ def build_graph(graphviz_graph, nodes, root_id, id_to_slices):
|
|
|
239
243
|
child_id = id(children[index])
|
|
240
244
|
build_graph_depth_first(graphviz_graph, nodes, child_id, id_to_slices, nodes_at_depth, subgraphed_nodes, depth+1)
|
|
241
245
|
if not node.is_hidden_node():
|
|
242
|
-
add_to_graphviz_graph(graphviz_graph, nodes, node, slices, id_to_slices
|
|
246
|
+
add_to_graphviz_graph(graphviz_graph, nodes, node, slices, id_to_slices)
|
|
243
247
|
|
|
244
248
|
nodes_at_depth = {}
|
|
245
249
|
build_graph_depth_first(graphviz_graph, nodes, root_id, id_to_slices, nodes_at_depth, set(), 0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memory_graph
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.59
|
|
4
4
|
Summary: Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy.
|
|
5
5
|
Author-email: Bas Terwijn <bterwijn@gmail.com>
|
|
6
6
|
License-Expression: BSD-2-Clause
|
|
@@ -169,7 +169,7 @@ Learn the right **mental model** to think about Python data. The [Python Data Mo
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
## Immutable Type ##
|
|
172
|
-
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` reference their own value afterwards.
|
|
172
|
+
In the code below variable `a` and `b` both reference the same tuple value (4, 3, 2). A tuple is an immutable type and therefore when we change variable `b` its value **cannot** be mutated in place, and thus an automatic copy is made and `a` and `b` each reference their own value afterwards.
|
|
173
173
|
|
|
174
174
|
```python
|
|
175
175
|
import memory_graph as mg
|
|
@@ -203,7 +203,7 @@ mg.render(locals(), 'mutable2.png')
|
|
|
203
203
|
|:-----------------------------------------------------------:|:-------------------------------------------------------------:|
|
|
204
204
|
| mutable1.png | mutable2.png |
|
|
205
205
|
|
|
206
|
-
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it.
|
|
206
|
+
One practical reason why Python makes the distinction between mutable and immutable types is that a value of a mutable type can be large, making it inefficient to copy each time we change it. Values of immutable type generally don't need to change as much, or are small, making copying less of a concern.
|
|
207
207
|
|
|
208
208
|
## Copying Values of Mutable Type ##
|
|
209
209
|
Python offers three different "copy" options that we will demonstrate using a nested list:
|
|
@@ -666,6 +666,9 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
666
666
|
- ***mg.config.render_filename*** : str
|
|
667
667
|
- The default filename to render to, default 'memory_graph.pdf'.
|
|
668
668
|
|
|
669
|
+
- ***mg.config.type_labels*** : bool
|
|
670
|
+
- If True the type of each node is shown as label, default True.
|
|
671
|
+
|
|
669
672
|
- ***mg.config.block_prints_location*** : bool
|
|
670
673
|
- If True the source location is printed in block(), default True.
|
|
671
674
|
|
|
@@ -712,7 +715,7 @@ Different aspects of memory_graph can be configured. The default configuration c
|
|
|
712
715
|
- Maximum number of missing edges that are shown with default value 2. Dashed references are used to indicate that there are more references to a node than are shown.
|
|
713
716
|
|
|
714
717
|
- ***mg.config.fontname*** : str
|
|
715
|
-
- The font used in the graph, default '
|
|
718
|
+
- The font used in the graph, default 'Times-Roman' (widely available on the web).
|
|
716
719
|
|
|
717
720
|
- ***mg.config.fontsize*** : str
|
|
718
721
|
- The font size used in the graph, default '14'.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "memory_graph"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.59"
|
|
8
8
|
description = "Teaching tool and debugging aid in context of references, mutable data types, and shallow and deep copy."
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "Bas Terwijn", email = "bterwijn@gmail.com"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|