Open-Source Wikis

/

CPython

/

Systems

python/cpython

Systems

This section documents the major subsystems of the CPython runtime — the parts that make ./python what it is. Each page is a focused tour of the code; the canonical authoritative references live under InternalDocs/ and are linked at the top of each page.

The compilation pipeline

graph LR
    SRC[Source] --> TOK[Tokens]
    TOK --> AST[AST]
    AST --> SYMBOLS[Symbol table]
    SYMBOLS --> INSTRS[Instruction sequence]
    INSTRS --> CFG[CFG + opts]
    CFG --> CODE[PyCodeObject]
Stage Page Files
Tokenize, parse Parser Parser/, Grammar/python.gram
AST → bytecode Compiler Python/compile.c, Python/codegen.c, Python/flowgraph.c, Python/assemble.c

Execution

Subsystem Page Files
Adaptive bytecode interpreter Interpreter Python/ceval.c, Python/bytecodes.c, Python/specialize.c
Tier-2 micro-op interpreter and JIT JIT and tier 2 Python/optimizer*.c, Python/jit.c
Exception handling Exception handling Objects/exceptions.c, Python/errors.c
Threading, GIL, free-threading Threading and the GIL Python/ceval_gil.c, Python/lock.c, Python/qsbr.c

Memory and the object model

Subsystem Page Files
Object model Object model Objects/object.c, Objects/typeobject.c, Include/object.h
Memory allocator Memory Objects/obmalloc.c, Objects/mimalloc/
Cycle GC Garbage collector Python/gc.c, Python/gc_free_threading.c

The import machinery

Subsystem Page Files
Imports Import system Python/import.c, Python/importdl.c, Lib/importlib/, Python/frozen_modules/

Reading order

If you are reading the wiki front-to-back, the recommended order is:

  1. Object model — every other system manipulates PyObject*.
  2. Memory — how those objects are allocated.
  3. Garbage collector — why long-lived programs don't leak.
  4. ParserCompiler — how source becomes PyCodeObject.
  5. InterpreterJIT and tier 2 — how PyCodeObject runs.
  6. Threading and the GIL, Exception handling, Import system — the cross-cutting concerns.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Systems – CPython wiki | Factory