LPython aggressively optimizes type-annotated Python code. It has several backends, including LLVM, C, C++, and WASM. LPython’s primary tenet is speed.

LPython is in alpha stage (meaning users enthusiastically participate in bug reporting and fixing). LPython will compile more of Python in the future, and accumulate more optimizations, experimental and production-ready. LPython makes it easy to write new back-ends for custom, exotic, or unusual hardware. Release blog post: LPython: Novel, Fast, Retargetable Python Compiler.

Main repository at GitHub: https://github.com/lcompilers/lpython Star

Try LPython in your browser using WebAssembly: https://dev.lpython.org/

Any questions? Ask us on Zulip project chat.

Key features of LPython

Simple, standard, fast

LPython is fast

LPython is built from the ground up to translate numerical, array-oriented code into simple, readable, and fast code.

Basic mathematics in the core language

Rich array operations, complex numbers, exponentiation, special functions, …

Simple but powerful

More restricting (and higher level) than languages like C or C++, so that the resulting code is easier to maintain and write and easier for the compilers to optimize. There is one canonical way to do things.

Just-In-Time (JIT)

LPython supports Just-in-time compilation which requires only decorating Python function with @lpython.

Interoperability with CPython

LPython offers seamless interoperability with CPython. One can easily call functions in CPython libraries

Open source

LPython, being an open-source project, enjoys the advantages of community collab, transparency, rapid bug resolution, enhanced security, knowledge exchange and more.

Feature Highlights

LPython is in heavy development, there are features that work today, and there are features that are being implemented.

Works today

  • Best possible performance for numerical, array-oriented code LPython gives you the speed you need for your numerical, array-oriented code. With LPython, you can write Python code that is as fast as C or C++. This is because LPython compiles your code to optimized machine code, which is the fastest way to run code on a computer.

  • Code compatibility with CPython If LPython compiles and runs a code, then it will run in CPython.

  • Seamless interoperability with CPython LPython can call functions in CPython libraries. This feature permits “break-out” to Numpy, TensorFlow, PyTorch, and even to matplotlib. The break-outs will run at ordinary (slow) Python speeds, but LPython accelerates the mathematical portions to near maximum speed.

  • Just-In-Time (JIT) compilation LPython also supports Just-in-time compilation which requires only decorating Python function with @lpython. One can also specify the desired backend, as in, @lpython(backend=“c”) or @lpython(backend=“llvm”). Only C is supported at present; LLVM and others will be added in the near future.

  • Clean, modular design, usable as a library LPython is structured around two independent modules, AST (Abstract Syntax Tree) and ASR (Abstract Semantic Representation), both of which are standalone (completely independent of the rest of LPython) and users are encouraged to use them independently for other applications and build tools on top. See the Design and Developer Tutorial documents for more details.

  • Create executables It can create fast optimized executables unlike other interpreted compilers.

  • Runs on Linux, Mac, Windows and WebAssembly All four platforms are regularly tested by our CI.

  • Several backends The LLVM can be used to compile to binaries and for interactive usage. The C/C++ backend translates Python code to a readable C/C++ code. The x86 backend allows very fast compilation directly to x86 machine code. The WebAssembly backend can quickly generate WASM.

Under Development

These features are under development:

  • Interactive, Jupyter support LPython is coming soon to Jupyter. It can be used as a Jupyter kernel, allowing Python/Julia-style rapid prototyping and an exploratory workflow (conda install jupyter lpython). It can also be used from the command-line with an interactive prompt (REPL).

  • Support for diverse hardware LLVM makes it possible to run LPython on diverse hardware. We plan to support a wide range of hardware platforms, including:

    • CPUs: compile Python code to run on CPUs of all architectures, including x86, ARM, and POWER.
    • GPUs: compile Python code to run on GPUs from NVIDIA, AMD, and Intel.
    • TPUs: compile Python code to run on TPUs from Google.

Please vote on issues in our issue tracker that you want us to prioritize (feel free to create new ones if we are missing anything).

Name Total Contributors Total stars
PyTorch 2857 69253
Pyston 1263 2426
mypyc 627 15995
JAX 523 24010
MicroPython 520 16998
Cython 435 8168
Numba 306 8790
CuPy 286 7062
Taichi 226 24023
PyPy 213 -
Triton 155 7846
Nuitka 138 9385
Brython 94 6058
Skulpt 91 3256
Pythran 58 1912
DaCe 58 419
LPython 44 1135
Weld 35 2945
IronPython 33 2179
Transcrypt 33 2727
Pyccel 32 279
Pyjs 30 1123
Grumpy 29 10580
Mojo 26 15569
uarray 22 98
Shedskin 20 701
Jython 18 897
Codon 12 13431
Compyle 11 67
Seq 9 680
Hope 6 385
Transonic 3 105

Note: we use “-” if there is no github repository. If any compiler is missing, or the stats are inaccurate, please let us know.