Zig–Python биндинги через CPython C-API

engineering

pyzig is a Claude Code skill that documents the Zig↔Python interoperability layer used by Faebryk's native modules, covering build-on-import mechanics, wrapper generation patterns, memory ownership rules, and where to add new exported APIs. The binding layer has three distinct parts: a Python loader (`__init__.py` handling `ZIG_NORECOMPILE`, `ZIG_RELEASEMODE`, and `.pyi` syncing), a Zig build file (`build.zig` that compiles `pyzig.so` and `pyzig_sexp.so` and generates stubs), and core utilities (`pybindings.zig`, `pyzig.zig`, `type_registry.zig`, `pyi.zig`). Zig structs are exposed as Python heap types via `wrap_in_python(...)` calling the CPython C-API directly — no cffi or ctypes involved. Use this skill when adding Zig-Python bindings for graph, sexp, or typegraph modules, modifying native extensions, or debugging pointer identity and C-API interactions.