stdlibinit

package
v0.12.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 43 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL