Skip to main content

Entity Specification

⚠️ Dark mode may make example images harder to see.

The draw function has an objects argument which is used to define the array of entities (type DrawnEntity) to be rendered on the canvas. This page documents the attributes of the DrawnEntity object type and provides examples for the different kinds of entities supported by MemoryViz.

Core Attributes

All supported entities include the following core attributes, unless explicitly stated otherwise:

AttributeTypeRequiredDescription
typestringYesSpecifies the type of object to be drawn. (e.g., .class, .frame, int, str). See Entity Type for more details.
idnumber or nullYesA unique identifier for the object. May be null anywhere to render a blank ID box.
valueanyYesThe content of the object to be drawn. Format depends on the entity type.
x, ynumberNoThe x and y coordinates for the object on the canvas. Required only if the automation parameter of draw is false.
styleobject or arrayNoCustom visual styling. See Style API for more details.

Entity Type

Type ValueDescription
int, float, str, bool, NonePrimitives
list, tupleSequences
setSets
dictDictionaries
.classClasses
.frameStack Frames
.blank .blank-frameBlank Objects

Primitives

AttributeTypeRequiredDescription
typestringYesMust be set to one of int, str, bool, float, or None to indicate a primitive object.
idnumberYesUnique identifier for the primitive object.
valueanyYesThe actual value represented by the primitive object. For types int and float, the value may be an empty or all-whitespace string to render a blank space.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

Integer
{
"type": "int",
"id": 19,
"value": 124
}

Example Integer

Blank integer
{
"type": "int",
"id": 19,
"value": ""
}

Example Blank Integer

String
{
"type": "str",
"id": 43,
"value": "David is cool"
}

Example String

Boolean
{
"type": "bool",
"id": 32,
"value": true
}

Example Boolean

Float
{
"type": "float",
"id": 76,
"value": 3.14
}

Example Float

Blank float
{
"type": "float",
"id": 76,
"value": ""
}

Example Blank Float

None
{
"type": "None",
"id": 0,
"value": "None"
}

Example None

Sequences

AttributeTypeRequiredDescription
typestringYesMust be set to list to indicate a list object, or tuple to indicate a tuple object.
idnumberYesUnique identifier for the sequence.
valuearrayYesList of object ids. Values can be made null to draw blank boxes.
show_indexesbooleanNoIndicates whether to show indices in the memory box. Defaults to false.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

List with blank boxes
{
"type": "list",
"id": 82,
"value": [19, 43, null, 49]
}

Example List

List with indices shown
{
"type": "list",
"id": 84,
"value": [32, 10, 90, 57],
"show_indexes": true
}

Example List with Indices

Tuple with blank boxes
{
"type": "tuple",
"id": 11,
"value": [82, 76, null]
}

Example Tuple

Tuple with indices shown
{
"type": "tuple",
"id": 11,
"value": [82, 76, null],
"show_indexes": true
}

Example Tuple with Indices

Sets

AttributeTypeRequiredDescription
typestringYesMust be set to set to indicate a set object.
idnumberYesUnique identifier for the set.
valuearrayYesList of object ids. Values can be made null to draw blank boxes.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

Set with blank boxes
{
"type": "set",
"id": 90,
"value": [36, 49, null, 64]
}

Example Set

Dictionaries

AttributeTypeRequiredDescription
typestringYesMust be set to dict to indicate a dictionary object.
idnumberYesUnique identifier for the dictionary.
valuedictYesDictionary of string object id keys to int object id value pairs. Keys can be made empty or all-whitespace strings and values can be made null to draw blank boxes.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

Dictionary with blank boxes
{
"type": "dict",
"id": 10,
"value": {
"": 81,
"1": null,
" ": 12
}
}

Example Dictionary

Classes

AttributeTypeRequiredDescription
typestringYesMust be set to .class to indicate a class object.
idnumberYesUnique identifier for the class object.
namestringYesThe name of the class being drawn.
valueobjectYesA mapping of attribute names (as keys) to object IDs (as values). Attribute names may be empty or all-whitespace strings and attribute values may be null to render blank boxes, respectively.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

Class with blank boxes
{
"type": ".class",
"id": 82,
"name": "Person",
"value": {
"age": 12,
"name": 17,
"": null
}
}

Example Class

Stack Frames

AttributeTypeRequiredDescription
typestringYesMust be .frame to indicate a stack frame.
idnullNoIgnored for stack frames and not rendered regardless of value.
namestringYesThe name of the stack frame (e.g., __main__, foo)
valueobjectYesA mapping of variable names (as keys) to object IDs (as values). These represent the local variables in the scope of the frame. Variable names may be empty or all-whitespace strings and attribute values may be null to render blank boxes, respectively.
x, ynumberNoOptional manual coordinates. Required only if automation is disabled.
styleobject or arrayNoCustom visual styling.

Examples

Main stack frame
{
"type": ".frame",
"name": "__main__",
"value": {
"lst1": 82,
"lst2": 84,
"p": 99,
"d": 10,
"t": 11
}
}

Example Main Stack Frame

Function stack frame with blank boxes
{
"type": ".frame",
"name": "func",
"value": {
"age": 12,
"name": 17,
"": null
}
}

Example Function Stack Frame

Blank Objects

AttributeTypeRequiredDescription
typestringYesMust be set to .blank to indicate a blank object, or .blank-frame to indicate a blank frame.
widthnumberYesThe width of the blank object/frame.
heightnumberYesThe height of the blank object/frame.

Examples

Blank object
{
"type": ".blank",
"width": 200,
"height": 100
}
Blank frame
{
"type": ".blank-frame",
"width": 200,
"height": 100
}