Skip to main content

Python Core Architecture Roadmap

From Language Semantics to CPython Runtime, Source Reading, and Engineering Judgment

Part 1: Python Language Semantics

Chapter 1: Execution Model

Chapter 2: Name Binding and Scope

Chapter 3: Object Reference Semantics

Chapter 4: Evaluation Semantics

Chapter 5: Control Flow Semantics

  • 5.1 if / while / for(条件分支、循环条件和迭代协议会被编译成跳转、比较、iterator 获取和异常结束路径)
  • 5.2 iterator-driven loopfor 会先调用 iter() 获得 iterator,再反复调用 next(),以 StopIteration 作为正常结束信号)
  • 5.3 break / continuebreak 跳出当前循环,continue 回到下一轮条件或迭代点,并与 finally cleanup 顺序交织)
  • 5.4 loop else 的语义(loop else 在循环自然结束时执行,被 break 中断时跳过,适合表达“搜索未提前命中”的控制流)
  • 5.5 pattern matching(match 会按 case 顺序执行结构匹配、类型/值检查、捕获绑定和解构,并在命中后进入对应 block)
  • 5.6 guard condition(case guard 在结构匹配成功后求值,guard 失败会继续尝试后续 case,并保留匹配语义的短路顺序)
  • 5.7 exception-driven flow(异常路径会切换控制流、保存 traceback、执行匹配 handler,并触发 finally/context manager cleanup)
  • 5.8 context-driven flowwithasync with 把入口、退出、异常处理和资源释放包装成协议驱动的控制流)

Chapter 6: Exception Semantics

Chapter 7: Context Management Semantics

  • 7.1 context manager protocol(context manager 用 __enter____exit__ 定义资源进入、绑定、异常接收和退出处理)
  • 7.2 with statementwith 会先求值 manager,调用 __enter__,执行 body,再把异常信息交给 __exit__
  • 7.3 __enter__ / __exit____enter__ 返回绑定值,__exit__ 接收 exc_type、exc、traceback,并用返回值决定异常是否继续传播)
  • 7.4 deterministic cleanup(文件、锁、事务、临时目录和网络连接可以通过 context manager 获得确定的退出顺序)
  • 7.5 exception suppression(当 __exit__ 返回真值时异常被吞掉,这会改变调用方看到的控制流和错误状态)
  • 7.6 async withasync with 使用 __aenter____aexit__,清理动作本身可以 await,适合异步连接、锁和 session)
  • 7.7 ExitStack / AsyncExitStack(ExitStack 动态注册多个退出回调,并按后进先出顺序释放资源,适合资源数量运行时才确定的场景)
  • 7.8 resource lifecycle management(资源生命周期分析需要确认获取点、所有权、退出顺序、异常路径和重复释放保护)

Part 2: Python Object System

Chapter 8: Everything Is Object

Chapter 9: Type System

Chapter 10: Attribute Lookup System

Chapter 11: Descriptor Protocol

Chapter 12: Function Object Internals

Chapter 13: Class Construction

Chapter 14: Inheritance and MRO

Chapter 15: Metaclass System

Part 3: Builtins and Core Protocols

Chapter 16: Built-in Functions

Chapter 17: Built-in Exceptions

Chapter 18: Core Protocols

Chapter 19: Iteration, Sequence, and Mapping Protocols

Chapter 20: Numeric, Comparison, and Hashing Protocols

Chapter 21: Callable, Context, Async, and Buffer Protocols

Part 4: Compilation Pipeline

Chapter 22: Tokenizer and PEG Parser

Chapter 23: AST and Symbol Table

Chapter 24: CFG and Bytecode Generation

Chapter 25: Bytecode Architecture

Chapter 26: Adaptive Runtime (PEP 659)

Part 5: Evaluation Runtime

Chapter 27: Execution Engine

  • 27.1 ceval.c(把 ceval.c 作为 bytecode 执行入口,定位 eval loop、opcode handler、frame 状态和 eval breaker)
  • 27.2 evaluation loop(evaluation loop 反复读取 opcode、操作 value stack、更新 instruction pointer,并在调用、异常、yield 时切换路径)
  • 27.3 opcode dispatch(opcode dispatch 决定当前指令进入哪个 handler,影响解释器分支成本、specialization 和调试阅读方式)
  • 27.4 stack VM 的运行方式(CPython bytecode 使用 value stack 传递中间值,表达式、调用、属性访问和异常都通过栈效果连接)
  • 27.5 instruction pointer 如何推进(instruction pointer 在普通指令、跳转、异常表、yield/resume 和 quickened instruction 中按不同规则推进)
  • 27.6 computed goto(computed goto 把 opcode dispatch 从集中 switch 变成直接跳转表,减少解释器分派开销)
  • 27.7 runtime dispatch(运行时分派会根据 opcode、object type、slot、descriptor、vectorcall 和 inline cache 选择具体执行路径)
  • 27.8 eval breaker(eval breaker 汇合 signal、pending call、GIL drop、async exception 等跨指令检查点)

Chapter 28: Execution State and Frame

Chapter 29: Callable Runtime

Chapter 30: Suspended Execution Model

Chapter 31: Async Runtime

Part 6: Memory System

Chapter 32: Reference Counting

Chapter 33: Garbage Collection

Chapter 34: Pymalloc Architecture

  • 34.1 arena / pool / block(pymalloc 把内存分成 arena、pool、block,用 size class 管理小对象分配与回收)
  • 34.2 small object allocator(小对象走 pymalloc 快速路径,大对象交给系统 allocator,二者会影响内存峰值和 profile 解读)
  • 34.3 freelist(tuple、list、frame 等对象可能使用 freelist 复用对象壳,释放后内存表现可能滞后于对象生命周期)
  • 34.4 allocator hierarchy(PyMem、PyObject、raw allocator、domain hook 形成多层 allocator 接口,扩展模块需要选对域)
  • 34.5 memory fragmentation(fragmentation 来自 size class、arena 保留、长寿命对象夹杂短寿命对象和 workload shape)
  • 34.6 allocation class(size class 决定对象进入哪个 pool,微小尺寸变化可能改变分配路径和内存占用)
  • 34.7 object reuse(对象复用会影响 id() 观察、内存调试、泄漏判断和 benchmark 稳定性)

Chapter 35: Immortal Objects (PEP 683)

  • 35.1 immortal object(immortal object 用特殊 refcount 表示长期存活对象,减少共享对象上的引用计数写入)
  • 35.2 cache line optimization(频繁修改 refcount 会造成 cache line 写压力,immortal object 能降低热门常量对象的写流量)
  • 35.3 GC bypass(部分 immortal/static 对象无需进入普通回收路径,阅读内存行为时要区分普通 heap object)
  • 35.4 runtime optimization(immortal object 服务解释器启动对象、内置单例、常用常量和多解释器共享对象的运行时成本控制)
  • 35.5 copy-on-write(fork 后共享内存页遇到 refcount 写入会触发 copy-on-write,immortal refcount 可减少这类写入)
  • 35.6 object sharing(多解释器和未来并行运行时需要更清楚地定义哪些对象可共享、哪些对象必须隔离)
  • 35.7 no-GIL preparation(no-GIL 方向需要降低全局共享对象上的原子写压力,immortal object 是其中一个支撑机制)
  • 35.8 immortal refcount(immortal refcount 是一个约定值,普通 INCREF/DECREF 路径会识别并保留该状态)

Part 7: Core Containers

Chapter 36: Dict Architecture

Chapter 37: List and Tuple Architecture

Chapter 38: Set Architecture

Chapter 39: Buffer and Binary Architecture

Part 8: Import System

Chapter 40: Import Semantics

Chapter 41: Import Machinery

Chapter 42: Module Object, sys.modules, and Import Cache

Chapter 43: Packages, Namespace Packages, and Resource Loading

Chapter 44: Import Failure, Finder Loader Contracts, and Diagnostics

Part 9: Concurrency Runtime

Chapter 45: GIL Internals

Chapter 46: Async Runtime Architecture

Chapter 47: Subinterpreters (PEP 684)

  • 47.1 subinterpreter(subinterpreter 在同一进程内创建独立解释器状态,用于隔离模块状态、线程状态和运行时资源)
  • 47.2 per-interpreter GIL(per-interpreter GIL 让不同解释器拥有各自锁,目标是让独立解释器中的 Python 代码并行执行)
  • 47.3 interpreter isolation(隔离重点是 module state、thread state、object ownership、extension module state 和 cross-interpreter data)
  • 47.4 parallel execution(并行收益取决于解释器隔离、可传输数据、扩展模块兼容性和任务粒度)
  • 47.5 runtime separation(runtime separation 要明确全局 runtime state、per-interpreter state、per-thread state 分别保存什么)
  • 47.6 interpreter state(PyInterpreterState 保存模块表、builtins、import state、GC state、thread list 和 runtime config 的解释器级状态)
  • 47.7 object isolation(对象跨解释器共享需要满足安全传递规则,普通 Python 对象通常通过复制、序列化或专门 channel 传递)

Chapter 48: Free-Threaded Python

  • 48.1 no-GIL architecture(free-threaded CPython 移除全局解释器锁后,需要重新设计 refcount、container lock、allocator 和 extension safety)
  • 48.2 lock strategy(list、dict、object state、runtime global state 需要更细粒度锁或无锁策略来保护并发访问)
  • 48.3 runtime tradeoff(free-threaded 模式提升 CPU 并行潜力,同时引入锁成本、原子操作成本、兼容性成本和调试复杂度)
  • 48.4 memory synchronization(并发线程之间的对象状态可见性依赖 atomic、lock、critical section 和 memory ordering 约束)
  • 48.5 atomic reference counting(引用计数更新需要支持并发安全,atomic refcount、biased/deferred 方案会改变对象生命周期成本)
  • 48.6 runtime redesign(解释器、GC、allocator、C API、extension state 都要围绕并发访问重新定义约束)
  • 48.7 CPython future roadmap(用 PEP 684、PEP 683、PEP 703 串起多解释器、immortal object、free-threaded 的演进关系)

Part 10: Standard Library Design

Chapter 49: Functional Abstraction

  • 49.1 itertools(itertools 用 C-level iterator 对象封装组合、截断、分组和笛卡尔积等惰性序列处理)
  • 49.2 functools(functools 提供 cached_property、lru_cache、partial、wraps、singledispatch 等 callable 包装和缓存工具)
  • 49.3 lazy evaluation(惰性求值把数据生产推迟到 next(),能降低内存峰值,也会改变错误触发时间)
  • 49.4 iterator pipeline(iterator pipeline 用一串 iterator 对象传递数据,每一步都需要考虑消费次数、短路和异常传播)
  • 49.5 higher-order function(高阶函数把行为作为对象传递,常见成本来自闭包、partial、descriptor binding 和 wrapper 层)
  • 49.6 callable adaptation(callable adaptation 会把函数、method、partial、descriptor、decorator 和 singledispatch 统一成可调用入口)
  • 49.7 generator composition(generator composition 通过 yield from、generator expression、chain 等方式组合惰性数据流)
  • 49.8 stream processing(stream processing 需要处理 backpressure、一次性消费、资源关闭和异常时的 cleanup)

Chapter 50: Runtime Introspection

  • 50.1 inspect(inspect 读取 function、class、module、frame、signature、source 等对象元数据,支撑调试和框架自省)
  • 50.2 runtime introspection(runtime introspection 通过 dirgetattr__dict__、MRO、descriptor 和 annotation 观察对象结构)
  • 50.3 signature(signature 还原 callable 参数种类、默认值、annotation、varargs 和 binding 规则)
  • 50.4 frame inspection(frame inspection 能读取调用栈、locals、globals、code object 和当前行号,也可能延长 frame 生命周期)
  • 50.5 source inspection(source inspection 依赖文件路径、linecache、loader、module metadata 和运行环境保留的源码)
  • 50.6 object metadata__name____qualname____module____annotations____doc____dict__ 构成对象可观察身份)
  • 50.7 runtime reflection(reflection 可以动态发现能力、构造调用、注册插件和生成文档,同时会削弱静态分析稳定性)
  • 50.8 dynamic analysis(dynamic analysis 通过 trace/profile hook、frame、dis、inspect 和 logging 捕捉真实运行路径)

Chapter 51: Typing and Runtime Boundary

Chapter 52: Context Managers and Resource Cleanup Architecture

  • 52.1 contextlib(contextlib 把生成器函数、回调栈和 decorator 包装成统一 context manager 工具层)
  • 52.2 ExitStack(ExitStack 允许运行时动态注册多个 context manager 和 cleanup callback,并按反向顺序退出)
  • 52.3 AsyncExitStack(AsyncExitStack 同时管理 async context manager、async callback 和 awaitable cleanup)
  • 52.4 deterministic cleanup(deterministic cleanup 让文件、锁、事务、临时状态在正常返回和异常路径上都有稳定释放点)
  • 52.5 context composition(context composition 需要处理多个资源获取失败时,已获取资源按正确顺序释放)
  • 52.6 resource lifetime(资源 lifetime 要标出 owner、borrower、transfer、release、close、cancel 和 finalizer 的责任边界)
  • 52.7 exception-safe cleanup(exception-safe cleanup 需要保证清理异常、原始异常、suppression 和 finally 顺序都可分析)

Chapter 53: Serialization Boundary

  • 53.1 json(json 只表达有限数据类型,适合跨语言数据交换,需要显式处理 datetime、decimal、bytes 和自定义对象)
  • 53.2 pickle(pickle 保存 Python 对象图和类路径,功能强但执行加载逻辑,适合可信边界内持久化)
  • 53.3 marshal(marshal 服务 CPython 内部字节码等低层格式,版本耦合强,适合读懂 .pyc 相关边界)
  • 53.4 object graph serialization(对象图序列化需要处理循环引用、共享引用、类型身份、版本演进和反序列化安全)
  • 53.5 security implications(整理 security implications 的触发条件、可见表现、运行时成本和边界)
  • 53.6 protocol version(pickle protocol version 决定 opcode、buffer 支持、兼容范围和跨版本读取能力)
  • 53.7 object identity preservation(pickle 可以保留对象共享关系,json 通常只保留值结构,这会影响缓存和恢复语义)
  • 53.8 binary serialization(二进制序列化要处理 endian、alignment、buffer ownership、zero-copy 和 native boundary)

Chapter 54: Filesystem and OS Abstraction

  • 54.1 pathlib(pathlib 把路径字符串包装成对象模型,区分 PurePath 语义和真实 filesystem 操作)
  • 54.2 os(os 模块暴露进程、文件描述符、权限、环境变量和系统调用风格接口)
  • 54.3 sys(sys 暴露解释器状态、模块表、路径、argv、exception info、trace hook 和 runtime 配置)
  • 54.4 filesystem abstraction(filesystem abstraction 要处理路径编码、权限、符号链接、atomic rename、临时文件和跨平台差异)
  • 54.5 process abstraction(process abstraction 连接 pid、exit code、signal、subprocess、stdin/stdout/stderr 和环境变量)
  • 54.6 environment variable(environment variable 是进程启动时继承的字符串配置,影响 import path、locale、runtime flag 和部署行为)
  • 54.7 file descriptor(file descriptor 是 OS 级资源句柄,Python file object 在其上叠加 buffering、encoding 和 context manager)
  • 54.8 path semantics(路径语义涉及 relative/absolute、cwd、home、case sensitivity、separator、drive、URI 和 sandbox)

Chapter 55: Concurrency Abstraction

  • 55.1 threading(threading 封装 OS thread、GIL 约束、lock、condition、local storage 和生命周期管理)
  • 55.2 multiprocessing(multiprocessing 用进程隔离绕开 GIL,代价是启动、pickle、IPC、共享内存和资源回收)
  • 55.3 asyncio(asyncio 用 event loop、Task、Future、transport/protocol 和 coroutine 调度协作式并发)
  • 55.4 concurrent.futures(futures 把线程池、进程池和异步结果包装成统一 submit/result/cancel 接口)
  • 55.5 synchronization primitives(Lock、RLock、Semaphore、Condition、Event、Queue 分别解决互斥、通知、容量和跨线程通信)
  • 55.6 process isolation(进程隔离让内存、GIL、崩溃影响和权限边界分离,同时引入序列化和 IPC 成本)
  • 55.7 executor abstraction(executor 把任务提交、worker 生命周期、结果获取、异常传播和 shutdown 包装成调度边界)
  • 55.8 async abstraction(async abstraction 需要关注取消、backpressure、任务泄漏、上下文传播和阻塞调用进入 event loop 的后果)

Part 11: Python C API

Chapter 56: Python C API Entry Points and Runtime Contract

Chapter 57: Extension Type System

Chapter 58: Embedding and Interop

  • 58.1 embedding Python(embedding 把 Python runtime 放入宿主进程,需要管理初始化、配置、GIL、module path 和 shutdown)
  • 58.2 runtime embedding(宿主程序要决定解释器生命周期、线程进入 Python 的方式、异常回传和多解释器隔离)
  • 58.3 native interop(native interop 连接 C/C++ 数据结构、Python object、异常、引用计数和调用约定)
  • 58.4 buffer sharing(buffer sharing 通过 Py_buffer、memoryview、NumPy-like protocol 减少复制,同时要求明确释放和写权限)
  • 58.5 C boundary cost(整理 C boundary cost 的触发条件、可见表现、运行时成本和边界)
  • 58.6 interpreter lifecycle(interpreter lifecycle 包括 preinit、config、initialize、import bootstrap、thread state、finalize 和资源析构顺序)
  • 58.7 embedded runtime(embedded runtime 需要把 Python 错误、日志、stdout/stderr、memory allocator 和 signal 行为映射回宿主系统)
  • 58.8 extension boundary(extension boundary 定义 native code 何时持有 GIL、谁拥有引用、如何返回错误、如何处理崩溃风险)

Chapter 59: Reference Ownership and Error Path Discipline

Chapter 60: Stable ABI, Limited API, and Extension Compatibility

Chapter 61: Buffer Protocol, Capsules, and Native Boundary Design

Part 12: CPython Source Reading

Chapter 62: CPython Source Tree

  • 62.1 Objects/Objects/ 承载核心对象实现,例如 type、dict、list、unicode、function、descriptor 和 GC 参与对象)
  • 62.2 Python/Python/ 承载解释器执行、编译、import、runtime 初始化、ceval、symtable 和错误处理等核心逻辑)
  • 62.3 Include/Include/ 暴露 C API、对象布局声明、宏、slot、runtime state 结构和 public/internal header 边界)
  • 62.4 Parser/Parser/ 负责 grammar、tokenizer、PEG parser、AST 入口和语法错误定位)
  • 62.5 Modules/Modules/ 放置内置扩展模块、C 实现标准库能力和平台相关模块)
  • 62.6 Lib/Lib/ 是 Python 实现标准库,能看到 importlib、asyncio、contextlib、inspect 等高层抽象如何组织)
  • 62.7 startup path(startup path 串起配置解析、runtime 初始化、path config、import bootstrap、main module 执行)
  • 62.8 runtime bootstrap(runtime bootstrap 建立内置类型、builtins、sys module、import system、thread state 和初始 interpreter state)

Chapter 63: typeobject.c

  • 63.1 type system(typeobject.c 展示 type 创建、metaclass 调用、slot 初始化、MRO 缓存和类型对象生命周期)
  • 63.2 descriptor lookup(attribute lookup 会按 data descriptor、instance dict、non-data descriptor、class attribute、fallback 的顺序处理)
  • 63.3 method binding(函数作为 descriptor 被读取时生成 bound method,把 instance 绑定成第一个参数)
  • 63.4 MRO logic(C3 linearization 把继承图转换为方法查找顺序,并在 class creation 时校验一致性)
  • 63.5 slot dispatch(numeric、sequence、mapping、call、getattro 等 slot 把 Python 操作连接到类型级 C 函数指针)
  • 63.6 special method lookup(special method 常从类型上查找,绕过部分实例属性路径,解释运算符和协议调用的特殊行为)

Chapter 64: dictobject.c

  • 64.1 compact dict(compact dict 把 sparse index 和 dense entries 分离,保留插入顺序并降低内存占用)
  • 64.2 probing algorithm(probing 使用 hash、perturb、empty/dummy slot 处理冲突、删除和查找终止)
  • 64.3 key-sharing dict(实例 dict 可以共享 key table,只保存各实例不同 value,降低大量对象的属性存储成本)
  • 64.4 dict resizing(resize 根据填充率和 dummy slot 状态扩容或重建,影响插入成本和内存峰值)
  • 64.5 hash strategy(hash、equality、randomization、string hash cache 共同决定 dict 查找正确性和攻击面)
  • 64.6 globals lookup optimization(globals/builtins lookup 会被版本 tag、inline cache、specialized opcode 加速)

Chapter 65: listobject.c and unicodeobject.c

  • 65.1 dynamic array(listobject.c 展示 over-allocation、resize、append、insert、slice 和 freelist 如何支撑 list 性能)
  • 65.2 unicode representation(unicodeobject.c 使用 kind、compact、ASCII flag、canonical data 表示不同字符范围的字符串)
  • 65.3 compact unicode(compact unicode 把对象头和字符数据放在连续内存中,降低访问和分配成本)
  • 65.4 memory optimization(list over-allocation、unicode compact layout、interning、freelist 都服务常见对象的内存/速度权衡)
  • 65.5 string caching(string interning、hash cache、identifier cache 会影响名字查找、dict key 和内存观察)

Chapter 66: descrobject.c and funcobject.c

  • 66.1 descriptor implementation(descrobject.c 展示 getset/member/wrapper/property 等 descriptor 如何把 C 字段和 Python attribute 连接)
  • 66.2 function object(funcobject.c 中 function object 持有 code、globals、defaults、kwdefaults、closure、annotations 和 vectorcall 入口)
  • 66.3 method object(method object 保存 function 与 self/class 的绑定关系,并参与调用路径)
  • 66.4 vectorcall(vectorcall 用连续参数数组和 flags 减少 tuple/dict 临时对象,优化高频调用)
  • 66.5 callable dispatch(callable dispatch 会经过 tp_call、vectorcall slot、method binding、argument parsing 和错误返回约定)
  • 66.6 property implementation(property 用 fget、fset、fdel、doc 组合成 data descriptor,解释 attribute 访问如何转为函数调用)

Chapter 67: genobject.c and frameobject.c

  • 67.1 generator object(genobject.c 展示 generator 如何保存 code/frame 状态、yield value、running flag 和关闭逻辑)
  • 67.2 coroutine object(coroutine object 与 generator 共享暂停机制,同时加入 awaitable 语义和 coroutine 状态检查)
  • 67.3 suspended frame(suspended frame 保留 instruction pointer、locals、value stack 和异常状态,等待下一次 resume)
  • 67.4 frame persistence(frame 被 generator/coroutine/traceback/inspect 持有时会延长局部对象生命周期)
  • 67.5 async runtime relation(asyncio Task 驱动 coroutine resume,异常、取消和返回值通过 Future/Task 状态传播)

Chapter 68: compile.c and symtable.c

  • 68.1 compiler pipeline(compiler pipeline 把 AST、symbol table、CFG、basic block、bytecode 和 exception table 串成源码到指令的转换链)
  • 68.2 symbol analysis(symtable.c 判断 local、global、free、cell、nonlocal、comprehension scope,决定后续 opcode 选择)
  • 68.3 bytecode generation(compile.c 将 AST 节点翻译为 stack effect、jump、const/name table 和 opcode sequence)
  • 68.4 AST traversal(AST traversal 保留语义结构、source location、作用域信息,并驱动语法特性进入编译阶段)
  • 68.5 compiler optimization(compiler optimization 会处理常量、跳转、basic block、stack depth 和版本相关指令形态)

Chapter 69: ceval.c

  • 69.1 evaluation loop(ceval.c 的 evaluation loop 负责逐条执行 bytecode、维护 value stack,并把调用/异常/yield 交给对应路径)
  • 69.2 opcode dispatch(opcode dispatch 通过 switch/computed goto/specialized instruction 将当前 opcode 路由到处理代码)
  • 69.3 specialization(specialization 利用 inline cache 和 runtime feedback 替换通用 opcode,优化常见类型路径)
  • 69.4 frame execution(frame execution 管理 fast locals、stack、block/exception state、return value 和 traceback 连接)
  • 69.5 runtime state(runtime state 包括 interpreter、thread、gil、pending calls、signals、recursion limit 和 eval breaker flags)
  • 69.6 eval breaker(eval breaker 让解释器在安全检查点处理 signal、pending call、GIL scheduling 和 async exception)

Chapter 70: gcmodule.c and obmalloc.c

  • 70.1 cyclic gc(gcmodule.c 通过 tracking、generation、traverse、clear 处理引用环和 container object)
  • 70.2 generation management(generation 管理对象年龄、collection 阈值、promotion 和 full collection 成本)
  • 70.3 object tracking(只有需要 GC 参与的 container object 被 tracking,atomic-like 对象通常走引用计数即可)
  • 70.4 pymalloc(obmalloc.c 通过 arena/pool/block、size class、free list 管理小对象内存)
  • 70.5 arena/pool/block(arena 来自系统 allocator,pool 服务同一 size class,block 是具体小对象分配单元)
  • 70.6 object reuse(object reuse 会影响内存峰值、id() 重用、泄漏排查和性能曲线)

Chapter 71: importlib asyncio and contextlib

  • 71.1 import system(importlib 展示 finder、loader、ModuleSpec、sys.modules cache、package path 和 lazy/error 边界)
  • 71.2 async runtime(asyncio 展示 event loop、Task、Future、transport、callback、cancellation 和 backpressure 的标准库组织方式)
  • 71.3 context manager abstraction(contextlib 展示 generator-based manager、ExitStack、async cleanup 如何统一资源生命周期)
  • 71.4 stdlib design pattern(标准库常用 protocol、duck typing、context manager、iterator、adapter、cache 和 wrapper 组织抽象)

Part 13: Runtime Evolution

Chapter 72: Parser and Compiler Pipeline Evolution

Chapter 73: Adaptive Interpreter, Specialization, and JIT Direction

Chapter 74: Immortal Objects, Memory Model, and Free-Threaded Python

Chapter 75: Subinterpreters, Isolation, and Runtime Parallelism

Chapter 76: Reading Future CPython Changes with Stable Models