mirror of https://github.com/exaloop/codon.git
976 B
976 B
Codon includes a build mode for generating Python extensions (which are traditionally written in C, C++ or Cython):
codon build -pyext extension.codon # add -release to enable optimizations
codon build -pyext
accepts the following options:
-o <output object>
: Writes the compilation result to the specified file.-module <module name>
: Specifies the generated Python module's name.
Functions
Extension functions written in Codon should generally be fully typed:
def foo(a: int, b: float, c: str): # return type will be deduced
return a * b + float(c)
The pyext
build mode will automatically generate all the necessary wrappers
and hooks for converting a function written in Codon into a function that's
callable from Python.
Function arguments that are not explicitly typed will be treated as generic Python objects, and operated on through the CPython API.