Announcing mojo-marimo: Run Mojo in Marimo Notebooks 🔥

Announcing mojo-marimo: Run Mojo in Marimo Notebooks :fire:

Status: Work in progress — Released for community feedback and testing

Version: v0.1.0 (Beta)

I’m excited to share mojo-marimo — a library that lets you run real Mojo code inside interactive Python notebooks using marimo.

Note: This executes Mojo via compilation and subprocess/FFI, not as a Mojo kernel.

This is an early release and I’m actively seeking feedback from the Mojo and Marimo communities on the approach, API design, and use cases.

What is it?

mojo-marimo provides three integration patterns for executing high-performance Mojo code from Python/marimo notebooks:

Pattern 1: Decorator — Pythonic & Clean

Mojo code lives in function docstrings with {{param}} templates. Call it like normal Python.

Example: notebooks/pattern_decorator.py

Pattern 2: Executor — Dynamic & Flexible

Pass Mojo code as strings or execute .mojo files. Perfect for dynamic code generation.

Example: notebooks/pattern_executor.py

Pattern 3: Extension Modules — Zero Overhead

Compile to .so files for direct Python imports. No subprocess, ~1000× faster calls.

Examples:

Trade-off: More complex Mojo code (requires PythonModuleBuilder), but eliminates subprocess overhead.

Key Features

  • :white_check_mark: Real Mojo compilation and execution
  • :white_check_mark: Smart caching (SHA256-based)
  • :white_check_mark: Three integration patterns
  • :white_check_mark: Pre-compilation validation
  • :white_check_mark: Interactive examples: Fibonacci, Monte Carlo π, Mandelbrot fractals
  • :white_check_mark: Works with marimo’s reactive model

Repository

:link: GitHub - DataBooth/py-run-mojo: Interactive Mojo integration for Python notebooks - three patterns for running high-performance Mojo code from marimo

44 passing tests (75% coverage) | Three integration patterns | Interactive examples | Comprehensive documentation

:bullseye: Feedback Requested!

See docs/FEEDBACK_REQUESTED.md for specific areas where community input would be valuable.

2 Likes

Definitely exciting but since you said Mojo Marimo allows you to run Mojo code inside python notebooks. My humble ask is wether I can run this on the Maturin CLI bridging Python with Rust inorder to use Mojo code instead of Python through C- ABI.

Hi @trojan_x - First I am not a Rust expert :slight_smile: and I am learning Mojo.

Thanks for the question! I want to make sure I understand correctly, as I’m not entirely certain about your use case. Some thoughts:

Current Architecture

mojo-marimo bridges Mojo → Python, not Mojo → Rust. It provides three patterns:

  1. Decorator/Executor: Compile Mojo to binaries, run via subprocess
  2. Extension modules: Compile Mojo to .so files that Python imports via FFI

Maturin, as I understand it, bridges Rust → Python (building Python packages from Rust code).

Possible Approaches

If you want Mojo and Rust in the same Python environment:

Maybe you could have both Mojo and Rust extension modules loaded in Python and call between them through Python:

Mojo (.so) → Python ← Rust (.so via Maturin)

Both would expose C-ABI functions that Python can call.

If you want direct Mojo → Rust (bypassing Python):

This wouldn’t involve mojo-marimo at all. You’d need both languages to expose C-compatible FFI and link them directly.

One link re Mojo/Python interop if helpful: Python interoperability | Modular

Clarification

Feel welcome to elaborate on what you’re trying to achieve? Are you looking to:

  • Call Mojo code from Rust code?
  • Use both Mojo and Rust extension modules in Python notebooks?
  • Something else I haven’t considered?

"Thanks for the breakdown, Michael. You’re spot on—the current ‘Python glue’ approach is the most stable.

However, for my project (an IPS for Cisco), I’m trying to minimize latency by bypassing the Python interpreter entirely. Since I’m using Rust for the security kernel (leveraging its memory safety and Maturin’s build system) and Mojo for the AI logic, I’m exploring a direct C-ABI link between them.

I’m happy to dive deeper into the Rust/Maturin side of things if that helps the community understand how to bridge these two high-performance worlds! It feels like the direct Mojo → Rust path is where the real ‘superpowers’ are for systems-level AI."

I’m looking for something like an FFI wrapper in Mojo that allows me to run Rust code in Mojo so that I can call Rust ML crates such as Smartcore, Linfa, Random Forest and Others. I’m heavily into sophisticated approach and to stop relying on python (Python.import_module (“Tensor flow “) libraries such as Tensor flow, Pytorch, Scikit learn and Nltk. And enthusiastic in using Memory safe code for building Autonomous security systems. I’m focused in the Mojo and Rust ecosystem with no more interest in diving into Slow and memory unsafe languages.

Yes now py-run-mojo - PyPI package here: Client Challenge