Molt
AOT compiler for a practical subset of Python. Produces small, fast native and WebAssembly binaries with broad stdlib and C extension compatibility.
Python has a deployment problem. Package management has gotten good (uv). But shipping a Python app as a single cross-platform binary -- no host interpreter, no megabytes of runtime -- is still painful.
Existing compilers fall into two camps. Codon compiles Python to native code but restricts the language so aggressively that most real-world Python breaks. Nuitka preserves compatibility but produces slow, bloated binaries and still bundles a CPython runtime. There is a gap between the two -- a compiler that is fast and small like Codon but compatible enough for real code like Nuitka. Molt targets that gap.
Molt is pre-release. The compiler produces working binaries and the coverage grows weekly, but it does not yet compile all Python.
Compiler pipeline
Written in Rust. Parses Python, analyzes the entire program to infer types, then strips unused code and eliminates unnecessary intermediate values. Native builds use Cranelift for fast development cycles and LLVM for optimized releases. WebAssembly output uses a custom emitter with wasm-opt for final size reduction.
The Cloudflare demo ships as a 2.8MB gzip binary on the free tier. Split-runtime mode separates app code from the shared runtime for independent CDN caching.
What it compiles
Classes with full inheritance. Async/await. Generators. Dataclasses. f-strings. Comprehensions. Exception handling. Most of the standard library -- math, json, itertools, functools, collections, asyncio, re, datetime, and more. C extensions supported through a compatibility layer (libmolt). Over 620 built-in operations implemented in the runtime.
Every commit runs differential tests against CPython 3.12+ to catch regressions.
Targets
Native: macOS, Linux (x86 and ARM), Windows. WebAssembly: browser, Cloudflare Workers (free tier, no cold start), Deno, Node, WASI. Luau (Roblox).
Monty integration
Designed to pair with Monty, a Python sandbox interpreter built by Pydantic. Use Monty during development for safe, fast iteration. Compile with Molt for production. When a function runs enough times in Monty, Molt compiles it ahead of time -- the same approach V8 and the JVM use to balance startup speed with peak performance.