A high-performance, zero-overhead, extensible Python compiler using LLVM
 
 
 
 
 
Go to file
Mark Henderson e880f5848a
Update docs ()
* Convert docs to Codon
2021-10-05 10:12:56 -05:00
.github Add CI 2021-10-05 10:54:42 -04:00
compiler Update grammar.peg 2021-10-05 10:41:26 -04:00
docs Update docs () 2021-10-05 10:12:56 -05:00
runtime Undo float formatting change 2021-10-05 10:43:12 -04:00
scripts Rename (wip) 2021-09-30 15:04:26 -04:00
stdlib Update docs () 2021-10-05 10:12:56 -05:00
test Namespace update to codon () 2021-10-04 13:10:59 -04:00
.clang-format Initial commit 2021-09-27 14:02:44 -04:00
.gitattributes Update .gitattributes 2021-10-03 11:18:57 -04:00
.gitignore Update .gitignore 2021-10-03 11:15:12 -04:00
CMakeLists.txt Rename (wip) 2021-09-30 15:04:26 -04:00
CODEOWNERS Initial commit 2021-09-27 14:02:44 -04:00
CONTRIBUTING.md Update docs () 2021-10-05 10:12:56 -05:00
LICENSE Initial commit 2021-09-27 14:02:44 -04:00
README.md Update docs () 2021-10-05 10:12:56 -05:00

README.md

Codon

Codon

Build Status Gitter Version License

Introduction

A strongly-typed and statically-compiled high-performance Pythonic language!

Codon is a programming language for computationally intensive workloads. With a Python-compatible syntax and a host of domain-specific features and optimizations, Codon makes writing high-performance software as easy as writing Python code, and achieves performance comparable to (and in many cases better than) C/C++.

Think of Codon as a strongly-typed and statically-compiled Python: all the bells and whistles of Python, boosted with a strong type system, without any performance overhead.

Codon is able to outperform Python code by up to 160x. Codon can further beat equivalent C/C++ code by up to 2x without any manual interventions, and also natively supports parallelism out of the box. Implementation details and benchmarks are discussed in our paper.

Learn more by following the tutorial.

Examples

Codon is a Python-compatible language, and many Python programs should work with few if any modifications:

def fib(n):
    a, b = 0, 1
    while a < n:
        print(a, end=' ')
        a, b = b, a+b
    print()
fib(1000)

This prime counting example showcases Codon's OpenMP support, enabled with the addition of one line. The @par annotation tells the compiler to parallelize the following for-loop, in this case using a dynamic schedule, chunk size of 100, and 16 threads.

from sys import argv

def is_prime(n):
    factors = 0
    for i in range(2, n):
        if n % i == 0:
            factors += 1
    return factors == 0

limit = int(argv[1])
total = 0

@par(schedule='dynamic', chunk_size=100, num_threads=16)
for i in range(2, limit):
    if is_prime(i):
        total += 1

print(total)

Install

Pre-built binaries

Pre-built binaries for Linux and macOS on x86_64 are available alongside each release. We also have a script for downloading and installing pre-built versions:

/bin/bash -c "$(curl -fsSL https://seq-lang.org/install.sh)"

Build from source

See Building from Source.

Documentation

Please check docs.exaloop.io for in-depth documentation.