Ondřej Čertík - LPython: Novel, Fast, Retargetable Python Compiler | SciPy 2024

Discover LPython, a groundbreaking Python compiler delivering fast compile times, runtime performance, and small binaries. Learn about its architecture and integration features at SciPy 2024.

Key takeaways
  • LPython is a novel, fast, retargetable Python compiler that aims to fix common Python issues like slow import time, low runtime performance, and packaging challenges

  • Key features:

    • Strict subset of CPython - anything that runs in LPython will run unmodified in CPython
    • Requires type annotations for compilation
    • Compiles to fast, lean binaries without Python dependencies
    • Interactive usage and binary compilation supported
    • Runs in Jupyter notebooks
    • WebAssembly backend available for browser execution
  • Architecture:

    • Front-ends: LPython (Python), LFortran (Fortran), LC (C++)
    • Uses Abstract Semantic Representation (ASR) as intermediate representation
    • Multiple backends including LLVM, WebAssembly, and high-level code generation (C, C++, Python, Fortran, Julia)
  • Performance characteristics:

    • Fast compilation times (30 seconds on Mac laptop)
    • Runtime performance competitive with or faster than C in some cases
    • Small binary sizes (~16KB)
    • No Python runtime dependency in compiled code
  • Development aspects:

    • Written in C++, compiles quickly
    • Small team (5-10 people)
    • Easy to extend with new frontends (2 months to add C++) and backends (2 weeks to 2 months)
    • Currently alpha stage but approaching beta
    • Clear error messages with GitHub issue reporting links
  • Integration capabilities:

    • Can call into C libraries
    • Python decorator interface similar to Numba
    • SymPy support for symbolic computation
    • NumPy array operations supported
    • OpenMP support for loop parallelization