What problem does it solve?
It solves the friction of integrating Mojo and Python by standardizing how you import Python code, convert values, handle Python exceptions, and expose Mojo functionality to Python.
Core Features & Use Cases
- Python from Mojo: Import Python modules, create Python values, and run Python expressions or modules via evaluation.
- Type conversions and interoperability: Convert Mojo primitives to Python objects using the correct py= keyword, and use ConvertibleToPython for automatic conversions or explicit to_python_object() when needed.
- PythonObject workflow: Use PythonObject for attribute access, calls, operators, indexing/slicing, iteration, and len without unnecessary conversions.
- Python extension modules: Build shared libraries using PythonModuleBuilder and export PyInit_<module_name> entry points with registered functions and types.
Quick Start
Use mojo-python-interop to call Python’s numpy from Mojo, pass arguments using py= where required, and catch Python exceptions as Mojo Error using raises.