# blink1073/oct2py architecture

> Architecture diagram of the GitHub repository blink1073/oct2py, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blink1073/oct2py
- Repository: https://github.com/blink1073/oct2py

## Overview

Oct2Py bridges Python code to GNU Octave: users invoke Octave functions or scripts through a managed session, exchange values, and receive converted results. The central session layer coordinates dynamic function dispatch, settings, and MAT-file-based exchange. The README also documents notebook magics, plotting, broad datatype support, independent sessions, and diagnostics. The graph reflects those documented capabilities; some internal call details are unsampled, so uncertain links are omitted.

Main entry points: [`oct2py/core.py`](https://github.com/blink1073/oct2py/blob/main/oct2py/core.py) (Session manager), [`oct2py/__init__.py`](https://github.com/blink1073/oct2py/blob/main/oct2py/__init__.py) (Public API), [`oct2py/ipython/octavemagic.py`](https://github.com/blink1073/oct2py/blob/main/oct2py/ipython/octavemagic.py) (OctaveMagic), [`oct2py/check.py`](https://github.com/blink1073/oct2py/blob/main/oct2py/check.py) (System check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Python interface"]
  node_api["Public API<br/>[__init__.py]"]
  node_version["Version metadata<br/>[_version.py]"]
end

subgraph group_session["Session runtime"]
  node_session["Session manager<br/>[core.py]"]
  node_settings["Session settings<br/>[settings.py]"]
  node_dispatch["Dynamic dispatch<br/>[dynamic.py]"]
  node_helpers["Runtime utilities<br/>[utils.py]"]
end

subgraph group_exchange["Data exchange"]
  node_exchange["MAT exchange<br/>[io.py]"]
end

subgraph group_notebook["Notebook and diagnostics"]
  node_magic["OctaveMagic<br/>[octavemagic.py]"]
  node_check["System check<br/>[check.py]"]
  node_demo["API demo<br/>[demo.py]"]
  node_speed["Speed check<br/>[speed_check.py]"]
  node_thread["Thread check<br/>[thread_check.py]"]
end

node_user(("Python user"))
node_octave(("GNU Octave"))

node_user -->|"uses"| node_api
node_api -->|"creates session"| node_session
node_api -->|"exports version"| node_version
node_session -->|"configures with"| node_settings
node_session -->|"uses dispatch"| node_dispatch
node_session -->|"uses utilities"| node_helpers
node_session -->|"exchanges values"| node_exchange
node_session -->|"runs commands"| node_octave
node_octave -->|"reads and writes"| node_exchange
node_magic -->|"uses sessions"| node_api
node_magic -->|"pushes and evaluates"| node_session
node_user -->|"loads extension"| node_magic
node_user -->|"runs check"| node_check
node_check -->|"tests connection"| node_session
node_user -->|"runs demo"| node_demo
node_demo -->|"uses API"| node_api
node_user -->|"runs benchmark"| node_speed
node_speed -->|"tests transfers"| node_session
node_user -->|"runs check"| node_thread

click node_api "https://github.com/blink1073/oct2py/blob/main/oct2py/__init__.py"
click node_version "https://github.com/blink1073/oct2py/blob/main/oct2py/_version.py"
click node_session "https://github.com/blink1073/oct2py/blob/main/oct2py/core.py"
click node_settings "https://github.com/blink1073/oct2py/blob/main/oct2py/settings.py"
click node_dispatch "https://github.com/blink1073/oct2py/blob/main/oct2py/dynamic.py"
click node_helpers "https://github.com/blink1073/oct2py/blob/main/oct2py/utils.py"
click node_exchange "https://github.com/blink1073/oct2py/blob/main/oct2py/io.py"
click node_magic "https://github.com/blink1073/oct2py/blob/main/oct2py/ipython/octavemagic.py"
click node_check "https://github.com/blink1073/oct2py/blob/main/oct2py/check.py"
click node_demo "https://github.com/blink1073/oct2py/blob/main/oct2py/demo.py"
click node_speed "https://github.com/blink1073/oct2py/blob/main/oct2py/speed_check.py"
click node_thread "https://github.com/blink1073/oct2py/blob/main/oct2py/thread_check.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_version,node_user toneBlue
class node_session,node_settings,node_dispatch,node_helpers toneAmber
class node_exchange toneMint
class node_magic,node_check,node_demo,node_speed,node_thread toneRose
class node_octave toneIndigo
```

## Components

### Python interface

- [Public API](https://github.com/blink1073/oct2py/blob/main/oct2py/__init__.py): `oct2py/__init__.py`
- [Version metadata](https://github.com/blink1073/oct2py/blob/main/oct2py/_version.py): `oct2py/_version.py`

### Session runtime

- [Session manager](https://github.com/blink1073/oct2py/blob/main/oct2py/core.py): `oct2py/core.py`
- [Session settings](https://github.com/blink1073/oct2py/blob/main/oct2py/settings.py): `oct2py/settings.py`
- [Dynamic dispatch](https://github.com/blink1073/oct2py/blob/main/oct2py/dynamic.py): `oct2py/dynamic.py`
- [Runtime utilities](https://github.com/blink1073/oct2py/blob/main/oct2py/utils.py): `oct2py/utils.py`

### Data exchange

- [MAT exchange](https://github.com/blink1073/oct2py/blob/main/oct2py/io.py): `oct2py/io.py`

### Notebook and diagnostics

- [OctaveMagic](https://github.com/blink1073/oct2py/blob/main/oct2py/ipython/octavemagic.py): `oct2py/ipython/octavemagic.py`
- [System check](https://github.com/blink1073/oct2py/blob/main/oct2py/check.py): `oct2py/check.py`
- [API demo](https://github.com/blink1073/oct2py/blob/main/oct2py/demo.py): `oct2py/demo.py`
- [Speed check](https://github.com/blink1073/oct2py/blob/main/oct2py/speed_check.py): `oct2py/speed_check.py`
- [Thread check](https://github.com/blink1073/oct2py/blob/main/oct2py/thread_check.py): `oct2py/thread_check.py`

### Other components

- **Python user**
- **GNU Octave**

## Connections

- Python user → Public API: uses (evidence: `README.md`)
- Public API → Session manager: creates session (evidence: `oct2py/__init__.py`)
- Public API → Version metadata: exports version (evidence: `oct2py/__init__.py`)
- Session manager → Session settings: configures with (evidence: `oct2py/core.py`)
- Session manager → Dynamic dispatch: uses dispatch (evidence: `oct2py/core.py`)
- Session manager → Runtime utilities: uses utilities (evidence: `oct2py/core.py`)
- Session manager → MAT exchange: exchanges values (evidence: `README.md`)
- Session manager → GNU Octave: runs commands (evidence: `README.md`)
- GNU Octave → MAT exchange: reads and writes (evidence: `README.md`)
- OctaveMagic → Public API: uses sessions (evidence: `oct2py/ipython/octavemagic.py`)
- OctaveMagic → Session manager: pushes and evaluates (evidence: `oct2py/ipython/octavemagic.py`)
- Python user → OctaveMagic: loads extension (evidence: `oct2py/ipython/octavemagic.py`)
- Python user → System check: runs check (evidence: `oct2py/check.py`)
- System check → Session manager: tests connection (evidence: `oct2py/check.py`)
- Python user → API demo: runs demo (evidence: `oct2py/demo.py`)
- API demo → Public API: uses API (evidence: `oct2py/demo.py`)
- Python user → Speed check: runs benchmark (evidence: `oct2py/speed_check.py`)
- Speed check → Session manager: tests transfers (evidence: `oct2py/speed_check.py`)
- Python user → Thread check: runs check
