Open and answer this issue on GitHub.
decision · opened 2026-11-12 · updated 2026-11-12 · 0 comments
An outside consultancy made suggestions to the owner on 2026-11-12. This is one of them: Python interoperability as Mojo has it, so that the Python ecosystem (numpy, pandas, ML libraries) is usable from Nikaia from day one. Half of this is decided. This issue files only the other half.
Interoperability with Python has two directions:
artifact = "c-library" exports a C ABI, and nikaia bind python generates a ctypes binding over it. ADR-284 §2 rejected PyO3-style native extension modules, one per language. Open work is in #112 and #88.numpy, and calls its functions with Nikaia values. Nothing covers this. Foreign code reaches Nikaia only from Rust crates (ADR-290, ADR-393) and through the C ABI.Calling Python means embedding the CPython interpreter in the Nikaia process, or talking to a separate Python process. It brings dynamic types into a statically typed program, reference counting and Python’s global interpreter lock across the boundary, and a run-time dependency on an installed Python.
The question: should Nikaia offer calling into Python? If so, in what form: an embedded interpreter, a separate process, or only through the C ABI that already exists? And under which permission?
nikaia bind python for the other direction.nikaia.toml.native (foreign code that the compiler cannot see), and a separate Python process is process. Either way, the caller’s package has to be granted it (#1434).These facts are from memory, not checked.
| Language | How it calls Python |
|---|---|
| Mojo | embeds CPython. Python.import_module("numpy") returns a PythonObject, a dynamically typed handle, and calls go through the interpreter at Python speed |
| Julia | PythonCall.jl / PyCall.jl embed CPython, and values are converted or wrapped |
| Rust | PyO3 can embed an interpreter as well as build extension modules. Calls return PyResult and need the GIL token |
| Swift | PythonKit (formerly in Swift for TensorFlow), dynamic member lookup over an embedded CPython |
| AILANG, Boruna, Vera, Dafny | no Python calls that I know of. Dafny compiles to Python instead |
std.process, permission process), or by wrapping it in C.
PyObject handle type. Values are converted at the boundary (int, float, str, list and dict as std types) and errors come back as Result. It is a package in packages/, not part of the language, and it needs the native permission.
.pyi files or typing annotations). A tool reads a module’s stubs and writes a typed Nikaia facade over option 2’s handle.
process.Option 1 for now. Write down in ADR-284 that the reverse direction is not provided and why, and come back to option 2, as a package and never as language syntax, once calling C libraries from Nikaia is decided. The consultancy’s “from day one” argument is about the ecosystem’s reach. Weigh it against keeping the permission and proof story whole: an embedded interpreter is one large native hole.
native / process permissions), #112 and #88 (the decided direction).packages/, how Nikaia calls a C library (possibly a gap to decide first), and the ownership of foreign handles.