
Ease of Python
Codon adopts Python's syntax, features and libraries, and is fully interoperable with Python
Performance of C
Codon uses LLVM to compile to native machine code, without vanilla Python's runtime overhead
Extensible
Codon is fully extensible via plugins that can add new libraries, optimizations or even syntax
How it Works
Codon at a Glance
cart = ['Apple', 'Apple', 'Pear']
cost = {'Apple': 1.20, 'Pear': 1.45}
x = sum(cost[item] for item in cart)
If you know Python, there's no learning curve to using Codon. Same syntax, semantics and builtin modules. Unlike Python, Codon compiles to native code and runs orders of magnitude faster.
from python import numpy as np
arr = np.arange(10)
print(arr ** 2)
Codon has out-of-the-box interoperability with Python, meaning you can take full advantage of Python's expansive ecosystem of libraries, from NumPy to Pandas to Tensorflow to Matplotlib.
@par(num_threads=4)
for i in range(10):
print(i ** 2)
Since Codon is implemented from the ground up as a new compiler, it doesn't have any of Python's multithreading limitations. Codon has full-fledged OpenMP support to take advantage of multiple cores.
def hypot(a: float, b: float) -> float:
from math import sqrt
return sqrt(a**2 + b**2)
Codon adopts the type annotation syntax introduced by newer Python versions. While type annotations can be used to enforce types statically, they are completely optional and can be inferred automatically.
@codon
def fib(n: int) -> int:
return n if n < 2 else fib(n-1) + fib(n-2)
Within larger Python codebases, Codon can be integrated on a per-function basis via the @codon
annotation to compile and optimize performance-critical segments of code.
from math import e, pi, sqrt
stirling = lambda n: sqrt(2*pi*n) * (n/e)**n
range(10) |> iter |> stirling |> print
Codon's new pipe operator |>
can succinctly express complex dataflow, and compiles down
to efficient code. Parallel pipelines are also supported via a parallel pipe operator ||>
.
Applications
Bioinformatics
Codon was initially developed to solve computing challenges in genomics and bioinformatics (see Seq), areas we continue to focus on heavily.
Finance
Codon's finance module accelerates and simplifies testing new trading strategies on large historical datasets.
Libraries
Codon-native versions of popular Python libraries offer enhanced performance, better memory footprints and library-specific compiler optimizations.
WebAssembly
Codon can target WebAssembly, allowing Python/Codon programs to run seamlessly in the browser.
GPUs
Codon allows GPU kernels to be written in plain Python, and facilitates GPU programming without having to resort to CUDA.
More
We're actively developing modules for a wide range of industries and sectors. Stay tuned for more!
×
Try Codon
We're launching our early adopter program. Contact us to learn more!