LPython compiles a typed subset of Python to fast binaries using LLVM, C, C++, x86, or WebAssembly backends. It targets numerical and array-oriented workloads and remains in active alpha development.
Overview
LPython is an ahead-of-time compiler written in C++ that translates annotated Python into optimized machine code or portable C and C++ sources. The focus is speed for numerical, array-oriented programs, eventual Jupyter use, cross-platform binaries, and gradual expansion toward broader Python coverage.
Today it aggressively optimizes type-annotated code, offers just-in-time decoration for functions, and can call into CPython libraries for areas such as NumPy or plotting at ordinary interpreter speed while accelerating math kernels. Multiple backends include LLVM, readable C or C++, direct x86, and WebAssembly, including browser trials. Executables can be generated without relying on a long-lived interpreter.
The design splits standalone abstract syntax and semantic representation modules so other tools can reuse them. Installed builds are supported on Linux, macOS, and Windows through Conda-based workflows. Interactive Jupyter and REPL workflows are forthcoming.
Compatibility goals aim for code LPython accepts to also run under CPython, while emphasizing diagnostics for errors and warnings during compilation.
Key features
- Ahead-of-time Python compilation
- LLVM, C, and WASM backends
- JIT via function decorators
- CPython library interoperability
- Numeric and array focus
- Standalone AST and ASR modules
- Cross-platform binary output
- Detailed compiler diagnostics
Use cases
- Accelerated numerical Python
- Compiled scientific utilities
- WebAssembly Python experiments
- Teaching compiler-friendly Python subsets