Documentation
¶
Overview ¶
Package sys ports cpython/Python/sysmodule.c. v0.7 lands the static-attribute slice (1651-sys-A): version strings, byteorder, maxunicode, builtin module names, hash info, the asyncgen hook slots. Each follow-on subtask attaches a slice of behavior:
- 1651-sys-B: argv, path, and modules from PyConfig
- 1651-sys-C: flags as a named tuple
- 1651-sys-D: stdout/stderr writers from the runtime
- 1651-sys-E: implementation tuple gopy fields
The dict is built once per interpreter via Init. Until 1623 lands the import system the dict is exposed directly to consumers (lifecycle, builtins) rather than landing in sys.modules.
CPython: Python/sysmodule.c:4131 _PySys_Create
Index ¶
Constants ¶
const DefaultRecursionLimit = 1000
DefaultRecursionLimit is CPython's Py_DEFAULT_RECURSION_LIMIT. The runtime sets this on every fresh interpreter; gopy keeps the same default until the per-thread recursion counter lands.
CPython: Include/cpython/pystate.h Py_DEFAULT_RECURSION_LIMIT
const ImplementationName = "gopy"
ImplementationName is the gopy fingerprint sys.implementation.name reports. Pinned per spec 1622 so consumers (importlib, third-party runners) can branch off "gopy" cleanly.
CPython: Python/sysmodule.c:3920 make_impl_info "name" entry
Variables ¶
var CacheTag = "gopy-" + strconv.Itoa(build.PythonMajorVersion) + strconv.Itoa(build.PythonMinorVersion) + "0"
CacheTag is the bytecode-cache-file tag CPython reports through sys.implementation.cache_tag. Encoded as "gopy-MMNNP" where MM is the upstream major, NN the minor, P the micro. The trailing zero is the third digit so .pyc files do not collide with cpython-NNN nor with future bumps to PY_MICRO_VERSION.
CPython: Python/sysmodule.c:3920 make_impl_info "cache_tag" entry
Functions ¶
func Bind ¶
Bind stamps the runtime helpers onto d: exit, setrecursionlimit, getrecursionlimit, getrefcount, intern. They live in a separate step because they capture the current thread (for SystemExit and the type-error path on intern). Init populates the static surface that does not need a thread.
CPython: Python/sysmodule.c:3892 _PySys_InitCore (function rows)
func Init ¶
Init builds the sys dict and stamps the static attributes that do not depend on PyConfig or runtime streams. Mirrors the _PySys_InitCore static slice.
CPython: Python/sysmodule.c:3822 _PySys_InitCore
func UpdateConfig ¶
func UpdateConfig(d *objects.Dict, cfg *initconfig.PyConfig) error
UpdateConfig stamps the PyConfig-derived attributes onto d: argv, orig_argv, path, warnoptions, _xoptions, executable, the prefix family, platlibdir, and pycache_prefix. Modules dict is installed once 1623 lands the import system.
This is the v0.7 port of _PySys_UpdateConfig: stringly-typed fields (executable, prefix, ...) become str; wide-string lists (argv, path, warnoptions) become tuples of str (CPython uses list, but a tuple is the right thing to expose until builtins wires up list literals).
CPython: Python/sysmodule.c:3951 _PySys_UpdateConfig
Types ¶
This section is empty.