100. Future Directions
Active PEPs, the free-threaded and JIT roadmaps, memory model work, and how to follow CPython development.
111 notes
Active PEPs, the free-threaded and JIT roadmaps, memory model work, and how to follow CPython development.
LOAD_METHOD and CALL_METHOD optimization, bound method objects, and the method cache.
The main evaluation loop in Python/ceval.c, opcode dispatch via computed gotos, and the eval breaker mechanism.
CPython security model: what is and is not sandboxed, restricted execution limits, and audit hook coverage.
pickle protocol versions, the __reduce__ / __reduce_ex__ protocol, marshal format, and shelve internals.
Circular import resolution, namespace package search order, zip imports, and __import__ hook edge cases.
What breaking the stable ABI costs, historical breakages, versioning policy, and the tradeoff against new features.
CPython 3.13 copy-and-patch JIT: template JIT design, trace selection, and the roadmap toward full JIT compilation.
PEP 684 per-interpreter GIL: isolated interpreter state, shared-nothing model, and module isolation requirements.
PEP 683 immortal objects: _Py_IMMORTAL_REFCNT sentinel, zero-cost incref/decref, and implications for forks.
PEP 703 no-GIL build: per-object locking, biased reference counting, and the free-threaded evaluation loop.
CPython version numbering, alpha/beta/RC schedule, branch management, and the role of the release manager.
PEP document structure, the steering council review process, and tracking PEP status on peps.python.org.
GitHub workflow: forking, branching, opening a PR, responding to review, and the CLA requirement.
Doc/ Sphinx source layout, building docs with make html, and the process for submitting documentation fixes.
test_* module conventions, unittest patterns, support helpers in Lib/test/support/, and writing C-level tests.
Valgrind suppression files, tracemalloc snapshot diffing, and libasan leak detection in CPython builds.
Building CPython with AddressSanitizer, UBSan, and ThreadSanitizer to catch memory and concurrency bugs.
CPython-aware GDB and LLDB scripts in Tools/gdb/, py-bt, py-list, and inspecting live interpreter frames.
Py_DEBUG compile flag, assertion macros, the --with-pydebug configure option, and debugging allocator.
python -m test flags, regrtest test selection, parallel execution (-j), and interpreting test output.
pyperformance benchmark suite, microbenchmark pitfalls, timer resolution, and interpreter warm-up effects.
Using perf, Instruments, and py-spy to profile CPython; reading perf maps generated by the JIT.
Object allocation locality, arena page placement, freelists for common types, and cache-line–aware design.
Type version tags, LOAD_ATTR inline cache hits, and the attribute specialization guards for slots and descriptors.
Compact dict memory layout, hash collision probing strategy, split-table sharing, and lookup specialization.
PEP 590 vectorcall protocol, _Py_TPFLAGS_HAVE_VECTORCALL, and stack-based argument passing for zero-overhead calls.
CALL_PY_EXACT_ARGS, CALL_BUILTIN_FAST, and the fast-path conditions that bypass the generic call machinery.
Adaptive counter logic, specialization guards, and how CPython 3.11+ rewrites opcodes to LOAD_ATTR_SLOT and friends.
Inline cache entries appended to CACHE instructions in the bytecode array and their layout per opcode family.
Computed goto dispatch table, the switch fallback, and how opcode prediction reduces branch mispredictions.
ctypes, cffi, and CFFI-based extension dispatch as the primary paths for calling C libraries from Python.
PyObject_Call, PyObject_CallNoArgs, argument tuple construction, and error checking after calling into Python.
Py_Initialize, PyConfig, embedding CPython in a host process, and managing interpreter lifetime.
Py_LIMITED_API version macros, symbols excluded from the limited API, and building abi3-compatible extensions.
The stable ABI symbol set, abi3 wheel tagging, and the constraints imposed by maintaining ABI compatibility.
PyCapsule_New, PyCapsule_GetPointer, and the pattern for passing opaque C pointers between extension modules.
Py_buffer, PyBUF_* flags, PyObject_GetBuffer, and implementing the buffer protocol in a custom type.
PyTypeObject slot-by-slot walkthrough: tp_new, tp_init, tp_dealloc, tp_methods, tp_getset, and inheritance.
PyModuleDef structure, PyModule_Create, multi-phase initialization (PEP 451), and module state.
Borrowed vs. owned references, Py_XDECREF patterns, and common reference counting mistakes in extensions.
Public C API overview, Include/ header organization, and the stable vs. internal API distinction.
asyncio event loop internals, the coroutine runner, I/O selector integration, and Task scheduling.
multiprocessing Process creation strategies (fork/spawn/forkserver), shared memory, and the pickle channel.
ctypes CDLL and WinDLL, fundamental types, Structure/Union layout, function prototypes, and libffi integration.
importlib.machinery finders and loaders, importlib.util helpers, and the Python-level import bootstrap.
types.FunctionType, types.CodeType, types.SimpleNamespace, and dynamic type creation with types.new_class.
gc.collect, gc.get_objects, gc.freeze, callbacks, and tuning generational thresholds.
dis.dis output, Instruction namedtuples, the bytecode iterator API, and reading adaptive specializations.
inspect.getmembers, signature objects, frame introspection, and source retrieval via linecache.
sys module fields that expose interpreter state: sys.modules, sys._getframe, sys.getsizeof, and audit hooks.
sys.addaudithook, the cpython.PyAudit_AddHook C API, and auditable events across the standard library.
PEP 567 Context and ContextVar objects, context copying on task creation, and asyncio integration.
Signal handler registration, the eval breaker flag, and safe SIGINT delivery to Python code.
Per-interpreter state isolation, Py_NewInterpreterFromConfig, and the experimental per-interpreter GIL.
Python thread objects, OS thread mapping, the GIL acquisition protocol, and thread-local state management.
GIL purpose, implementation in Python/ceval_gil.c, forced release intervals, and its effect on multi-core performance.
C3 linearization algorithm, mro() computation, and how Python resolves method lookup across multiple inheritance.
type.__new__ and type.__init__, __init_subclass__, __set_name__, and metaclass resolution order.
__get__, __set__, __delete__ protocol, data vs. non-data descriptors, and property/classmethod/staticmethod internals.
The per-module import lock, re-entrant import detection, and deadlock scenarios in multithreaded code.
Package __init__.py, namespace packages (PEP 420), relative imports, and __path__ manipulation.
The import machinery: finders, loaders, sys.modules cache, and the importlib bootstrap sequence.
MAKE_CELL, LOAD_DEREF, STORE_DEREF opcodes and the PyCellObject that captures variables in enclosing scopes.
How list/dict/set comprehensions and generator expressions compile to nested code objects with implicit iteration.
match/case compilation to MATCH_* opcodes, pattern semantics, and guard evaluation in the interpreter.
async def, await, SEND opcode, coroutine wakeup, and how asyncio integrates with CPython's coroutine machinery.
Generator object internals, YIELD_VALUE and RESUME opcodes, and frame suspension and resumption mechanics.
Exception tables, the try/except/finally bytecode pattern, exception chaining, and the unwinding protocol.
LOAD_ATTR bytecode, __getattribute__ dispatch, the descriptor protocol, and type version tag caching.
CALL opcode mechanics, positional and keyword argument handling, *args/**kwargs unpacking, and call overhead.
Catalogue of CPython opcodes: LOAD/STORE variants, binary ops, comparison, jumps, and call instructions.
The value stack, operand push/pop discipline, and how the interpreter maintains stack depth invariants.
PyFrameObject and _PyInterpreterFrame layout, frame creation, the frame stack, and frame introspection.
Peephole optimizer passes: constant folding, dead code elimination, and superinstruction formation in Python/flowgraph.c.
Instruction emission, jump fixup, and the assembler in Python/compile.c that produces the final bytecode array.
How compile-time constants are folded, names interned, and local variable slots assigned in the code object.
PyCodeObject fields: co_code, co_consts, co_names, co_varnames, co_filename, and how they are used at runtime.
Multi-pass lowering from AST to CFG to linear bytecode, and the role of each compiler pass in Python/compile.c.
Scope analysis in Python/symtable.c: local, global, free, and cell variable classification before compilation.
AST node types defined in Parser/Python.asdl, the ast module, and how AST nodes map to source locations.
CPython's PEG parser, Grammar/python.gram, the generated Parser/parser.c, and parse tree construction.
Tokenize module internals, the C tokenizer in Parser/tokenize.c, and how indentation becomes INDENT/DEDENT tokens.
PyLongObject digit array for arbitrary precision, PyFloatObject IEEE 754 storage, and complex number layout.
Compact dict implementation, hash table probing, split-key sharing, and PySetObject collision resolution.
PyListObject dynamic resizing strategy, PyTupleObject immutability, and the array module's typed buffer.
PyUnicodeObject internal encodings, the interning table, bytes vs. bytearray, and the codec infrastructure.
C-level implementations of None, True, False, NotImplemented, and Ellipsis as statically allocated objects.
PyTypeObject slot layout, tp_* function pointers, and how type slots encode object behavior for the interpreter.
The pymalloc small-object allocator, arenas, pools, blocks, and when CPython falls back to system malloc.
Cycle detection algorithm, generational collection, gc thresholds, and the interaction with reference counting.
Py_INCREF, Py_DECREF, and the deterministic lifetime rules that drive most memory reclamation in CPython.
The PyObject and PyVarObject C structs: ob_refcnt, ob_type, and the ob_size extension for variable-length objects.
How every value in Python is a heap-allocated object, and the role of type objects in defining behavior.
End-to-end journey of a .py file through lexing, parsing, compilation, and bytecode evaluation.
The interpreter state, thread state, frame stack, and the runtime lifecycle from Py_Initialize to Py_Finalize.
Conventions, macros, naming patterns, and header layout used throughout the CPython C codebase.
Tour of the CPython source tree: Modules/, Objects/, Python/, Parser/, Include/, and the build system.
Cloning the repository, installing dependencies, running ./configure, and compiling CPython from source.
What CPython is, how it differs from other Python implementations, and why its internals are worth studying.
Free-threaded CPython, immortal objects, per-interpreter GIL, JIT work, stable ABI design tradeoffs, import system edge cases, serialization internals, security boundaries, and future directions.
Running the test suite, debug builds, GDB and LLDB, sanitizers, tracing memory bugs, writing core tests, documentation, making patches, reading PEPs, and the release process.
Interpreter dispatch, inline caches, the specializing adaptive interpreter, function call fast paths, vectorcall, dictionary and attribute access performance, memory locality, profiling, and benchmarking.
The Python C API, reference ownership rules, creating extension modules, defining new types, the buffer protocol, capsules, stable ABI, limited API, embedding Python, and cross-language calls.
How sys, inspect, dis, gc, types, importlib, ctypes, multiprocessing, and asyncio bridge Python code to CPython internals.
Modules and imports, packages, the import lock, descriptors, classes and metaclasses, the MRO, the GIL, threads, subinterpreters, signals, context variables, and audit hooks.
The evaluation loop, frames, stack-based execution, bytecode instructions, function and method calls, attribute lookup, exceptions, generators, coroutines, pattern matching, comprehensions, and closures.
Tokenization, parsing, the AST, symbol tables, compiler passes, code objects, constants and locals, bytecode generation, and bytecode optimization.
The Python object model, PyObject and PyVarObject layout, reference counting, the garbage collector, memory allocators, and built-in type implementations.
What CPython is, building from source, the repository layout, reading C code, the runtime model, and the path from source code to execution.
A deep read of CPython: architecture, object model, memory management, compilation pipeline, and the evaluation loop.