From c0427540aa04e23113aa53a97ca63516201614b5 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 28 Oct 2025 16:14:22 -0300 Subject: [PATCH 1/2] Doc: Add sphinx.ext.graphviz extension dependency --- Doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/conf.py b/Doc/conf.py index a8e376c0ae44fe..49576acced479c 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -38,6 +38,7 @@ 'sphinx.ext.coverage', 'sphinx.ext.doctest', 'sphinx.ext.extlinks', + 'sphinx.ext.graphviz', ] # Skip if downstream redistributors haven't installed them @@ -560,6 +561,10 @@ } extlinks_detect_hardcoded_links = True +# Options for sphinx.ext.graphviz +# ------------------------------- +graphviz_output_format = 'svg' + # Options for c_annotations extension # ----------------------------------- From c0dd3c47119daeb33f02222d9b0c1fe66c6063d3 Mon Sep 17 00:00:00 2001 From: Adorilson Bezerra Date: Tue, 28 Oct 2025 16:35:29 -0300 Subject: [PATCH 2/2] Doc: Convert the execution model "textual" diagram to a visual diagram (it uses graphivz) --- Doc/reference/executionmodel.rst | 87 ++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index 639c232571edf3..974b203533e9c5 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -412,9 +412,35 @@ its operating system (OS), if there is one. When a program runs, the conceptual layers of how it runs on the host look something like this: - | **host machine** - | **process** (global resources) - | **thread** (runs machine code) +.. graphviz:: + + digraph general_comput_model { + graph [ + bgcolor=white, + splines=false, + overlap=false, + rankdir=TB, + ]; + + subgraph cluster_host { + label="host machine"; + style=filled; + color=lightgrey; + penwidth=2; + shape=ellipse; + + subgraph cluster_process { + label="process\n(global resources)"; + style=filled; + color=white; + penwidth=2; + + thread [label="thread\n(runs machine code)", + style=filled, fillcolor=lightgreen]; + + } + } + } Each process represents a program running on the host. Think of each process itself as the data part of its program. Think of the process' @@ -471,12 +497,55 @@ Python Runtime Model The same conceptual layers apply to each Python program, with some extra data layers specific to Python: - | **host machine** - | **process** (global resources) - | Python global runtime (*state*) - | Python interpreter (*state*) - | **thread** (runs Python bytecode and "C-API") - | Python thread *state* +.. graphviz:: + + digraph python_exec_model { + graph [ + bgcolor=white, + splines=false, + overlap=false, + rankdir=TB, + ]; + + subgraph cluster_host { + label="host machine"; + style=filled; + color=lightgrey; + penwidth=2; + shape=ellipse; + + subgraph cluster_process { + label="process\n(global resources)"; + style=filled; + color=white; + penwidth=2; + + subgraph cluster_runtime { + label="Python global runtime\n(state)"; + style=filled; + color=lightyellow; + penwidth=2; + + subgraph cluster_interpreter { + label="Python interpreter\n(state)"; + style=filled; + color=lightblue; + penwidth=2; + + subgraph cluster_thread { + label="thread\n(runs Python bytecode and C-API)"; + style=filled; + color=lightgreen; + penwidth=2; + + thread_state [label="Python thread state", + style=filled, fillcolor=white]; + } + } + } + } + } + } At the conceptual level: when a Python program starts, it looks exactly like that diagram, with one of each. The runtime may grow to include