Setu 2026.11.9
static
YoSTEALTH/Setu
Edit

Writing a Setu extension#

Setu turns ordinary Zig into a CPython module: you write pub fns and structs, Setu writes the C-ABI trampolines, the type objects, the docstrings and the .pyi stub. One binary loads on CPython 3.14, 3.14t, 3.15, 3.15t and later. This guide is the working reference for a session that writes bindings with Setu (in Setu's own test/, in Liburing, in Shakti). Read section 1 first; the rest is lookup. Every signature here is Setu's current one; Setu refuses what it can not express with a @compileError that says why (section 10), so compile early.

Where things are: setu.py (the one namespace to use: references, conversions, raising, the module), setu.c (the C API, hand-declared, every object opaque), setu.Class, setu.Exception, setu.Module, setu.From, setu.CallArgs, setu.Visit, setu.Send, setu.Poll. The test extension test/ of Setu has one class per hook family (test/class.zig), one function per parameter type (test/function.zig) and the model root file (test/setu_class.zig); test/class_test.py shows what each does from Python.

Generated by tool/setu_doc.py from the docstrings of Setu 2026.11.9.