# gvanrossum/cpython architecture

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

- Interactive diagram: https://gitdiagram.com/gvanrossum/cpython
- Repository: https://github.com/gvanrossum/cpython

## Overview

CPython is the Python interpreter and its standard library. The main executable initializes the runtime and dispatches module execution; the standard library supplies language-adjacent and application capabilities. The graph includes substantial core modules named by the source index, but not every library module. Evidence is limited to the README, source-index references, and shown excerpts: arrows are included only where those sources identify a caller or documented entry point.

Main entry points: [`Lib/multiprocessing/managers.py`](https://github.com/gvanrossum/cpython/blob/main/Lib/multiprocessing/managers.py) (Shared objects), [`Lib/xmlrpc/server.py`](https://github.com/gvanrossum/cpython/blob/main/Lib/xmlrpc/server.py) (XML-RPC server), [`Modules/main.c`](https://github.com/gvanrossum/cpython/blob/main/Modules/main.c) (Interpreter entry), [`Lib/traceback.py`](https://github.com/gvanrossum/cpython/blob/main/Lib/traceback.py) (Tracebacks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Interpreter runtime"]
  node_main["Interpreter entry<br/>[main.c]"]
  node_module_run["Module execution<br/>[runpy.py]"]
end

subgraph group_api["C interfaces"]
  node_public_api["Public C API<br/>[Python.h]"]
  node_internal_long["Integer internals<br/>[pycore_long.h]"]
end

subgraph group_stdlib["Standard library"]
  node_argparse["CLI parsing<br/>[argparse.py]"]
  node_email_message["Email messages<br/>[message.py]"]
  node_email_content["Email content<br/>[contentmanager.py]"]
  node_http_client["HTTP client<br/>[client.py]"]
  node_http_server["HTTP server<br/>[server.py]"]
  node_inspect["Object inspection<br/>[inspect.py]"]
  node_os["Operating system<br/>[os.py]"]
  node_pickle["Object serialization<br/>[pickle.py]"]
  node_pydoc["Documentation tools<br/>[pydoc.py]"]
  node_shutil["File utilities<br/>[shutil.py]"]
  node_traceback["Tracebacks<br/>[traceback.py]"]
  node_typing["Type annotations<br/>[typing.py]"]
  node_unittest["Test runner<br/>[main.py]"]
end

subgraph group_concurrency["Concurrency and networking"]
  node_queue["Thread queues<br/>[queue.py]"]
  node_threading["Threading<br/>[threading.py]"]
  node_managers["Shared objects<br/>[managers.py]"]
  node_xmlrpc["XML-RPC server<br/>[server.py]"]
end

node_user(("Python user"))

node_user -->|"starts interpreter"| node_main
node_main -->|"runs module"| node_module_run
node_email_content -->|"reads and updates"| node_email_message
node_unittest -->|"parses options"| node_argparse
node_managers -->|"uses OS services"| node_os
node_managers -->|"uses tracebacks"| node_traceback
node_managers -->|"uses queues"| node_queue
node_managers -->|"uses threads"| node_threading
node_xmlrpc -->|"serves over HTTP"| node_http_server
node_xmlrpc -->|"uses inspection"| node_inspect
node_xmlrpc -->|"uses documentation"| node_pydoc
node_xmlrpc -->|"uses tracebacks"| node_traceback

click node_main "https://github.com/gvanrossum/cpython/blob/main/Modules/main.c"
click node_module_run "https://github.com/gvanrossum/cpython/blob/main/Lib/runpy.py"
click node_public_api "https://github.com/gvanrossum/cpython/blob/main/Include/Python.h"
click node_internal_long "https://github.com/gvanrossum/cpython/blob/main/Include/internal/pycore_long.h"
click node_argparse "https://github.com/gvanrossum/cpython/blob/main/Lib/argparse.py"
click node_email_message "https://github.com/gvanrossum/cpython/blob/main/Lib/email/message.py"
click node_email_content "https://github.com/gvanrossum/cpython/blob/main/Lib/email/contentmanager.py"
click node_http_client "https://github.com/gvanrossum/cpython/blob/main/Lib/http/client.py"
click node_http_server "https://github.com/gvanrossum/cpython/blob/main/Lib/http/server.py"
click node_inspect "https://github.com/gvanrossum/cpython/blob/main/Lib/inspect.py"
click node_os "https://github.com/gvanrossum/cpython/blob/main/Lib/os.py"
click node_pickle "https://github.com/gvanrossum/cpython/blob/main/Lib/pickle.py"
click node_pydoc "https://github.com/gvanrossum/cpython/blob/main/Lib/pydoc.py"
click node_shutil "https://github.com/gvanrossum/cpython/blob/main/Lib/shutil.py"
click node_traceback "https://github.com/gvanrossum/cpython/blob/main/Lib/traceback.py"
click node_typing "https://github.com/gvanrossum/cpython/blob/main/Lib/typing.py"
click node_unittest "https://github.com/gvanrossum/cpython/blob/main/Lib/unittest/main.py"
click node_queue "https://github.com/gvanrossum/cpython/blob/main/Lib/queue.py"
click node_threading "https://github.com/gvanrossum/cpython/blob/main/Lib/threading.py"
click node_managers "https://github.com/gvanrossum/cpython/blob/main/Lib/multiprocessing/managers.py"
click node_xmlrpc "https://github.com/gvanrossum/cpython/blob/main/Lib/xmlrpc/server.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_main,node_module_run,node_user toneBlue
class node_public_api,node_internal_long toneAmber
class node_argparse,node_email_message,node_email_content,node_http_client,node_http_server,node_inspect,node_os,node_pickle,node_pydoc,node_shutil,node_traceback,node_typing,node_unittest toneMint
class node_queue,node_threading,node_managers,node_xmlrpc toneRose
```

## Components

### Interpreter runtime

- [Interpreter entry](https://github.com/gvanrossum/cpython/blob/main/Modules/main.c): `Modules/main.c`
- [Module execution](https://github.com/gvanrossum/cpython/blob/main/Lib/runpy.py): `Lib/runpy.py`

### C interfaces

- [Public C API](https://github.com/gvanrossum/cpython/blob/main/Include/Python.h): `Include/Python.h`
- [Integer internals](https://github.com/gvanrossum/cpython/blob/main/Include/internal/pycore_long.h): `Include/internal/pycore_long.h`

### Standard library

- [CLI parsing](https://github.com/gvanrossum/cpython/blob/main/Lib/argparse.py): `Lib/argparse.py`
- [Email messages](https://github.com/gvanrossum/cpython/blob/main/Lib/email/message.py): `Lib/email/message.py`
- [Email content](https://github.com/gvanrossum/cpython/blob/main/Lib/email/contentmanager.py): `Lib/email/contentmanager.py`
- [HTTP client](https://github.com/gvanrossum/cpython/blob/main/Lib/http/client.py): `Lib/http/client.py`
- [HTTP server](https://github.com/gvanrossum/cpython/blob/main/Lib/http/server.py): `Lib/http/server.py`
- [Object inspection](https://github.com/gvanrossum/cpython/blob/main/Lib/inspect.py): `Lib/inspect.py`
- [Operating system](https://github.com/gvanrossum/cpython/blob/main/Lib/os.py): `Lib/os.py`
- [Object serialization](https://github.com/gvanrossum/cpython/blob/main/Lib/pickle.py): `Lib/pickle.py`
- [Documentation tools](https://github.com/gvanrossum/cpython/blob/main/Lib/pydoc.py): `Lib/pydoc.py`
- [File utilities](https://github.com/gvanrossum/cpython/blob/main/Lib/shutil.py): `Lib/shutil.py`
- [Tracebacks](https://github.com/gvanrossum/cpython/blob/main/Lib/traceback.py): `Lib/traceback.py`
- [Type annotations](https://github.com/gvanrossum/cpython/blob/main/Lib/typing.py): `Lib/typing.py`
- [Test runner](https://github.com/gvanrossum/cpython/blob/main/Lib/unittest/main.py): `Lib/unittest/main.py`

### Concurrency and networking

- [Thread queues](https://github.com/gvanrossum/cpython/blob/main/Lib/queue.py): `Lib/queue.py`
- [Threading](https://github.com/gvanrossum/cpython/blob/main/Lib/threading.py): `Lib/threading.py`
- [Shared objects](https://github.com/gvanrossum/cpython/blob/main/Lib/multiprocessing/managers.py): `Lib/multiprocessing/managers.py`
- [XML-RPC server](https://github.com/gvanrossum/cpython/blob/main/Lib/xmlrpc/server.py): `Lib/xmlrpc/server.py`

### Other components

- **Python user**

## Connections

- Python user → Interpreter entry: starts interpreter (evidence: `README.rst`)
- Interpreter entry → Module execution: runs module (evidence: `Modules/main.c`)
- Email content → Email messages: reads and updates (evidence: `Lib/email/contentmanager.py`)
- Test runner → CLI parsing: parses options (evidence: `Lib/unittest/main.py`)
- Shared objects → Operating system: uses OS services (evidence: `Lib/multiprocessing/managers.py`)
- Shared objects → Tracebacks: uses tracebacks (evidence: `Lib/multiprocessing/managers.py`)
- Shared objects → Thread queues: uses queues (evidence: `Lib/multiprocessing/managers.py`)
- Shared objects → Threading: uses threads (evidence: `Lib/multiprocessing/managers.py`)
- XML-RPC server → HTTP server: serves over HTTP (evidence: `Lib/xmlrpc/server.py`)
- XML-RPC server → Object inspection: uses inspection (evidence: `Lib/xmlrpc/server.py`)
- XML-RPC server → Documentation tools: uses documentation (evidence: `Lib/xmlrpc/server.py`)
- XML-RPC server → Tracebacks: uses tracebacks (evidence: `Lib/xmlrpc/server.py`)
