Draw a graph of your data to see the structure of its references.
Project description
Graph your Memory
Want to draw a graph of your data in Python to better understand its structure or the Python memory model in general?
Just call "memory_graph.show(your_data)", an example:
import memory_graph
data = [ (1, 2), [3, 4], {5:'five', 6:'six'} ]
memory_graph.show( data )
This shows the graph with the starting point of your 'data' drawn using thick lines, the program blocks until the key is pressed.
If show()
doesn't work well on your system (the PDF viewer integration
is platform specific) use render()
to output the graph in the format
of your choosing. Use block=False
to turn off blocking.
memory_graph.render( data, "my_graph.png", block=False)
Larger Example
This larger example shows objects that share a class (static) variable and also shows a recursive reference.
import memory_graph
my_list = [10, 20, 30]
class My_Class:
my_class_var = 1000 # class variable: shared by different objects
def __init__(self):
self.var1 = "foo"
self.var2 = "bar"
obj1 = My_Class()
obj2 = My_Class()
data=[my_list, my_list, obj1, obj2]
my_list.append(data) # recursive reference
memory_graph.show( data )
Install
Install using pip:
pip install memory-graph
Author
Bas Terwijn
Inspiration
Inspired by PythonTutor.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for memory_graph-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b1cf9d7ba51d99346f20ec11dff7d9ec6f8e620457a4efb69ab540124bb0f96 |
|
MD5 | f7792189bf4813f46bed5a761851961c |
|
BLAKE2b-256 | 6e9928d37f1e342a87771e3e3c980709f7e9cdd07cb891c69559bed03b1b38ce |