Skip to content

5. Runtime Systems

Modules and imports, packages, the import lock, descriptors, classes and metaclasses, the MRO, the GIL, threads, subinterpreters, signals, context variables, and audit hooks.

ChapterTitle
40Modules and Imports
41Packages
42The Import Lock
43Descriptors
44Classes and Metaclasses
45The MRO
46The GIL
47Threads
48Subinterpreters
49Signals
50Context Variables
51Audit Hooks
40. Modules and ImportsThe import machinery: finders, loaders, sys.modules cache, and the importlib bootstrap sequence.
24 min
41. PackagesPackage __init__.py, namespace packages (PEP 420), relative imports, and __path__ manipulation.
17 min
42. The Import LockThe per-module import lock, re-entrant import detection, and deadlock scenarios in multithreaded code.
14 min
43. Descriptors__get__, __set__, __delete__ protocol, data vs. non-data descriptors, and property/classmethod/staticmethod internals.
14 min
44. Classes and Metaclassestype.__new__ and type.__init__, __init_subclass__, __set_name__, and metaclass resolution order.
17 min
45. The MROC3 linearization algorithm, mro() computation, and how Python resolves method lookup across multiple inheritance.
16 min
46. The GILGIL purpose, implementation in Python/ceval_gil.c, forced release intervals, and its effect on multi-core performance.
15 min
47. ThreadsPython thread objects, OS thread mapping, the GIL acquisition protocol, and thread-local state management.
16 min
48. SubinterpretersPer-interpreter state isolation, Py_NewInterpreterFromConfig, and the experimental per-interpreter GIL.
17 min
49. SignalsSignal handler registration, the eval breaker flag, and safe SIGINT delivery to Python code.
13 min
50. Context VariablesPEP 567 Context and ContextVar objects, context copying on task creation, and asyncio integration.
14 min
51. Audit Hookssys.addaudithook, the cpython.PyAudit_AddHook C API, and auditable events across the standard library.
18 min