exaloop /codon

A high-performance, zero-overhead, extensible Python compiler with built-in NumPy support

★ 16,860⑂ 607
PythonCreated 2021-09-27docs.exaloop.io
16,860
stars
+-3+-4+2
607
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions

README

Docs
   &183; 
  FAQ
   &183; 
  Blog
   &183; 
  Discord
   &183; 
  Roadmap
   &183; 
  Benchmarks



  


 What is Codon?

Codon is a high-performance Python implementation that compiles to native machine code without
any runtime overhead. Typical speedups over vanilla Python are on the order of 10-100x or more, on
a single thread. Codon's performance is typically on par with (and sometimes better than) that of
C/C++. Unlike Python, Codon supports native multithreading, which can lead to speedups many times
higher still.

Think of Codon as Python reimagined for static, ahead-of-time compilation, built from the ground
up with best possible performance in mind.

 Goals

- :bulb: No learning curve: Be as close to CPython as possible in terms of syntax, semantics and libraries
- :rocket: Top-notch performance: At least on par with low-level languages like C, C++ or Rust
- :computer: Hardware support: Full, seamless support for multicore programming, multithreading (no GIL!), GPU and more
- :chart_with_upwards_trend: Optimizations: Comprehensive optimization framework that can target high-level Python constructs
  and libraries
- :battery: Interoperability: Full interoperability with Python's ecosystem of packages and libraries

 Non-goals

- :x: Drop-in replacement for CPython: Codon is not a drop-in replacement for CPython. There are some
  aspects of Python that are not suitable for static compilation — we don't support these in Codon.
  There are ways to use Codon in larger Python codebases via its JIT decorator
  or Python extension backend. Codon also supports
  calling any Python module via its Python interoperability.
  See also "Differences with Python" in the docs.

- :x: New syntax and language constructs: We try to avoid adding new syntax, keywords or other language
  features as much as possible. While Codon does add some new syntax in a couple places (e.g. to express
  parallelism), we try to make it as familiar and intuitive as possible.

 How it works


 


 Quick start

Download and install Codon with this command:

bash
/bin/bash -c "$(curl -fsSL https://exaloop.io/install.sh)"


After following the prompts, the codon command will be available to use. For example:

- To run a program: codon run file.py
- To run a program with optimizations enabled: codon run -release file.py
- To compile to an executable: codon build -release file.py
- To generate LLVM IR: codon build -release -llvm file.py

Many more options are available and described in the docs.

Alternatively, you can build from source.

 Examples

 Basics

Codon supports much of Python, and many Python programs will work with few if any modifications.
Here's a simple script fib.py that computes the 40th Fibonacci number...

 python
from time import time

def fib(n):
    return n if n < 2 else fib(n - 1) + fib(n - 2)

t0 = time()
ans = fib(40)
t1 = time()
print(f'Computed fib(40) = {ans} in {t1 - t0} seconds.')


... run throu

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON