Documentation
¶
Overview ¶
Package stdlibinit is the gopy equivalent of CPython's Modules/config.c.in. The C build generates that file with one extern declaration plus one _PyImport_Inittab[] row per built-in module; the linker then materializes the inittab at startup.
gopy uses Go init() blocks instead: each module package (module/gc/, module/contextvars/, ...) calls imp.AppendInittab from its own init(). Those init blocks only run when their package is imported somewhere in the dependency graph. Without a central registration site, cmd/gopy/main.go would have to blank-import every module package by hand, and forgetting one means import gc silently raises ModuleNotFoundError at runtime.
This package centralizes that registration: blank-importing stdlibinit pulls in every gopy module package, which forces every init() to run, which populates imp.Inittab. cmd/gopy/main.go blank-imports stdlibinit and nothing else has to change.
CPython: Modules/config.c.in:26 _PyImport_Inittab[] CPython: Python/import.c:2403 _PyImport_FindBuiltin