Python Integrates Mojo: A Leap Towards High-Performance Coding

Brad Larson, the product manager at AI company Modular, has announced that users can now invoke Mojo code within Python. Mojo is a superset of Python that brings additional capabilities for high-performance coding, taking full advantage of modern accelerators.

This language was introduced in 2023 by Chris Lattner, the creator of the Swift programming language, during his tenure at Modular.AI.

The section regarding Python compatibility in the Mojo documentation has been expanded to include a dedicated guide on calling Mojo from Python. Developers have added a couple of new examples to the Modular GitHub repository: a «hello world» example that demonstrates transitioning between Python and Mojo, and another example that showcases how Mojo code utilizing GPU resources can be invoked from Python. The script can be utilized through various installation methods for MAX (Modular Accelerated Execution platform, an integrated set of AI computing tools) and Mojo compiler: via `pip install modular` / `pip install max` or with Conda using Magic / Pixi.

«We believe that enabling selective migration of performance bottlenecks in Python code to fast Mojo, especially Mojo operating on accelerators, will unlock entirely new applications,» Larson stated.

The manager encouraged users to review the current limitations to avoid bugs and prevent the submission of duplicate reports regarding known issues.

«We’re genuinely excited to see what you create with this new functionality, and we look forward to your feedback on how to improve it further,» Larson concluded.

Due to Mojo’s open license, it can be used free of charge on any device for research, hobbyist, or educational projects. The Mojo SDK toolkit is also available, allowing for the compilation of AI projects on local systems.

In the latest TIOBE programming language rankings, «fast» languages that can handle large datasets in environments where hardware cannot keep up with growing demands have seen an increase. Mojo is striving to break into the top 50.