mojo-python-interop - Mojo-Python Interoperability Guide
Guide for writing Mojo code that interoperates with Python using current syntax and conventions
Tags
Updated: 2026-05-28Capabilities
Typical Inputs
Typical Outputs
What this skill does
- import Python modules
- convert Python objects to Mojo types
- convert Mojo types to Python objects
- create Python collections
- evaluate Python code
- handle Python exceptions
- call Python functions
- access Python object attributes
- iterate Python collections
- build Python extension modules
- export Mojo functions to Python
- export Mojo types to Python
- register Python module methods
- wrap Mojo structs
Inputs
- Python modules
- Mojo source files
- Python objects
- Mojo types
- Python code strings
Outputs
- Python extension modules
- Mojo-converted Python objects
- Python-converted Mojo objects
- shared libraries
- Python code execution results
Requirements
- Mojo compiler
- Python environment
- shared library support
- std.python module
- PythonModuleBuilder
- compatible build flags
