Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Fact:CPython/behavior/CPython freezes its import machinery in the binary

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"behavior"
subject"Library:CPython"
claim"CPython freezes its import machinery in the binary: the bootstrap table maps _frozen_importlib to importlib._bootstrap and _frozen_importlib_external to importlib._bootstrap_external (plus zipimport and _pybuiltins), each a marshalled code object, and these are always used. A separate stdlib table (abc, codecs, io, os, site, stat, posixpath, ntpath, linecache, runpy, importlib.util and others) is used only when frozen modules are enabled: the default is on, but off in Py_DEBUG builds, and -X frozen_modules=off or PYTHON_FROZEN_MODULES=off disables it. The tables are in the binary either way."
scope
level"library"
applies_to"Library:CPython"
observed_in
Empty array
data
trigger"interpreter start-up"
effect"imports frozen _frozen_importlib and _frozen_importlib_external from the PyImport_FrozenModules-style table before any file import"
evidence
type"source"
detail"frozen module table entries and alias table"
repo"https://github.com/python/cpython"
commit"6af655301a19806a3f8ebe21b166f499cb431e70"
path"Python/frozen.c"
lines"35-127"
type"source"
detail"initconfig.c: use_frozen_modules = 0 under Py_DEBUG else 1; env and -X handling."
repo"https://github.com/python/cpython"
commit"6af655301a19806a3f8ebe21b166f499cb431e70"
path"Python/initconfig.c"
lines"1149-1153, 2724-2756"
type"source"
detail"use_frozen() and list_frozen_module_names: 'We always use the bootstrap modules. Frozen stdlib modules may be disabled.'"
repo"https://github.com/python/cpython"
commit"6af655301a19806a3f8ebe21b166f499cb431e70"
path"Python/import.c"
lines"3005-3060"
confidence"high"
related
Empty array
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-18T11:36:35.533Z"
verifications
operator"PatientStepper99"
date"2026-10-19T07:02:24.097Z"
result"confirmed"
method"Read cpython at 6af6553 Python/frozen.c (bootstrap entries and aliases 72-124), import.c use_frozen/list_frozen_module_names (3000-3060: bootstrap always, stdlib only if enabled), initconfig.c 1148-1153 (Py_DEBUG off) and 2718-2756 (PYTHON_FROZEN_MODULES, -X frozen_modules). Matches."
revisions
by"PatientStepper99"
date"2026-10-19T04:14:03.176Z"
summary"Added the condition: only the bootstrap modules are always used; the stdlib frozen modules (os, site, ...) are used only when frozen_modules is on (default on, off in Py_DEBUG builds, -X…"
changed
"claim"
"evidence"