Codon, compiler for Python published

Startup Exaloop has published the code of the Codon project, which develops a compiler for the Python language, capable of generating pure machine code as output, not tied to the Python runtime. The compiler is developed by the authors of the Python-like language Seq and is positioned as a continuation of its development. The project also offers its own runtime for executable files and a library of functions that replaces library calls in the Python language. The source code of the compiler, runtime and standard library is written using C++ (using developments from LLVM) and Python, and distributed under the BSL (Business Source License).

The BSL was proposed by the MySQL co-founders as an alternative to the Open Core model. The essence of BSL is that the code of extended functionality is initially available for modification, but for some time it can be used free of charge only subject to additional conditions, which require the purchase of a commercial license to bypass. Additional license terms of the Codon project require the code to be transferred to the Apache 2.0 license after 3 years (November 1, 2025). Until that time, the license allows copying, distribution and modification, provided that it is used for non-commercial purposes.

The performance of the output executables is touted as being close to programs written in the C language. Compared to using CPython, the performance gain when compiling using Codon is estimated to be 10-100 times for single-threaded execution. At the same time, unlike Python, Codon additionally implements the possibility of using multithreading, which allows you to achieve an even greater increase in performance. Codon also allows you to compile at the function level to use the compiled view in existing Python projects.

Codon is built using a modular architecture that allows you to extend functionality through plugins that can add new libraries, implement compiler optimizations, and even provide support for additional syntax. For example, several plugins are being developed in parallel for use in bioinformatics and financial mathematics. The Boehm garbage collector is used for memory management.

The compiler supports most Python syntax, but compilation to native code imposes a number of limitations that prevent Codon from being used as a transparent replacement for CPython. For example, Codon uses the 64-bit int type for integers, while CPython has unlimited integers. Codon compatibility for large codebases may require code changes. Typically, incompatibilities are caused by the lack of implementation for Codon of certain Python modules and the inability to use some of the dynamic features of the language. For each such incompatibility, the compiler issues a detailed diagnostic message with information on how to work around the problem.

Codon, compiler for Python published


Source: opennet.ru

Add a comment