python.util

Helper functions to interact with the Python C API

Members

Functions

createModule
auto createModule()

Creates a Python module from the given C functions. Each function has the same name in Python.

createModule
auto createModule(PyMethodDef[] methods)

Create a Python module. The strings are compile-time parameters to avoid passing GC-allocated memory to Python (by calling std.string.toStringz or manually appending the null terminator).

createModuleMixin
string createModuleMixin()

A string mixin to reduce boilerplate when creating a Python module. Takes a module name and a variadic list of C functions to make available.

pyMethodDef
auto pyMethodDef(PyCFunction cfunction)

Helper function to create PyMethodDef structs. The strings are compile-time parameters to avoid passing GC-allocated memory to Python (by calling std.string.toStringz or manually appending the null terminator).

Structs

CFunctions
struct CFunctions(functions...)

For a nicer API

Module
struct Module

For a nicer API

Meta