Mojo module
bindings
Aliases
GenericPyFunction
alias GenericPyFunction = Variant[fn(mut PythonObject, mut PythonObject) -> PythonObject, fn(mut PythonObject, mut PythonObject, mut PythonObject) -> PythonObject, fn(mut PythonObject, mut PythonObject) raises -> PythonObject, fn(mut PythonObject, mut PythonObject, mut PythonObject) raises -> PythonObject]
MOJO_PYTHON_TYPE_OBJECTS
alias MOJO_PYTHON_TYPE_OBJECTS = _Global["MOJO_PYTHON_TYPE_OBJECTS", __init__[StringSlice[StaticConstantOrigin], PythonObject, AHasher[0]]]
Mapping of Mojo type identifiers to unique PyTypeObject* binding that Mojo type to this CPython interpreter instance.
PyFunction
alias PyFunction = fn(mut PythonObject, mut PythonObject) -> PythonObject
The generic function type for non-raising Python bindings.
The first argument is the self object, and the second argument is a tuple of the
positional arguments. These functions always return a Python object (could be a
None object).
PyFunctionRaising
alias PyFunctionRaising = fn(mut PythonObject, mut PythonObject) raises -> PythonObject
The generic function type for raising Python bindings.
The first argument is the self object, and the second argument is a tuple of the
positional arguments. These functions always return a Python object (could be a
None object).
PyFunctionWithKeywords
alias PyFunctionWithKeywords = fn(mut PythonObject, mut PythonObject, mut PythonObject) -> PythonObject
The generic function type for non-raising Python bindings with keyword arguments.
The first argument is the self object, the second argument is a tuple of the positional arguments, and the third argument is a dictionary of the keyword arguments.
PyFunctionWithKeywordsRaising
alias PyFunctionWithKeywordsRaising = fn(mut PythonObject, mut PythonObject, mut PythonObject) raises -> PythonObject
The generic function type for raising Python bindings with keyword arguments.
The first argument is the self object, the second argument is a tuple of the positional arguments, and the third argument is a dictionary of the keyword arguments.
Structs
-
PyMojoObject: Storage backing a PyObject* wrapping a Mojo value. -
PythonModuleBuilder: A builder for creating Python modules with Mojo function and type bindings. -
PythonTypeBuilder: A builder for a Python 'type' binding.
Functions
-
check_and_get_arg: Get the argument at the given index and downcast it to a given Mojo type. -
check_and_get_or_convert_arg: Get the argument at the given index and convert it to a given Mojo type. -
check_arguments_arity: Validate that the provided arguments match the expected function arity. -
lookup_py_type_object: Retrieve a reference to the unique Python type describing Python objects containing Mojo values of typeT.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!