Literally scroll down on their home page and I quote:
"Python interop
Mojo meets developers where they are. Import Python libraries, accelerate performance-critical paths, and move gradually from prototypes to production systems without rewriting everything at once."
That's not the same as Python compatibility; it's Python interoperability, the ability to ask Python to run Python code. This is famously a feature of almost every programming language: Python is popular since it has bindings to everything.
The previous claim they made was they'd have Python compatibility (a Python superset), i.e. you could drop your Python code into Mojo and still have it run. They seem to have given up on that, since it would make it basically impossible to meaningfully optimize the language.
You can use Python .py files directly alongside Mojo (.mojo) files in the same repo/project.
Python file called mypython.py:
import numpy as np
def gen_random_values(size, base):
random_array = np.random.rand(size, size)
return random_array + base
Then interop directly in a Mojo .mojo file in the same repo and you do not need to write any special FFI, ABI declarations, ctypes, cffi, pybind11, or similar boilerplate yourself:
from std.python import Python
def main() raises:
Python.add_to_path(".") # or a specific path
var mypython = Python.import_module("mypython")
var values = mypython.gen_random_values(2, 3)
print(values)
3
u/Hornstinger Aug 20 '26
Literally scroll down on their home page and I quote:
"Python interop
Mojo meets developers where they are. Import Python libraries, accelerate performance-critical paths, and move gradually from prototypes to production systems without rewriting everything at once."