r/ProgrammingLanguages • Inko • Aug 18 '26

Blog post Mojo🔥 is now open source!

https://www.modular.com/blog/mojo-open-source
159 Upvotes

65 comments sorted by

View all comments

Show parent comment

2

u/Hornstinger Aug 23 '26

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)

2

u/Llamas1115 Aug 25 '26 edited Sep 29 '26

I mean, yeah, that's language interop. Don't get me wrong, the interop looks fine, but this isn't really special.