Nuitka
   HOME

TheInfoList



OR:

Nuitka (pronounced as ) is a
source-to-source compiler A source-to-source translator, source-to-source compiler (S2S compiler), transcompiler, or transpiler is a type of translator that takes the source code of a program written in a programming language as its input and produces an equivalent sou ...
which compiles
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
code to C source code, applying some compile-time optimizations in the process such as constant folding and propagation, built-in call prediction,
type inference Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistic ...
, and conditional statement execution. Nuitka initially was designed to produce C++ code, but current versions produce C source code using only those features of
C11 C11, C.XI, C-11 or C.11 may refer to: Transport * C-11 Fleetster, a 1920s American light transport aircraft for use of the United States Assistant Secretary of War * Fokker C.XI, a 1935 Dutch reconnaissance seaplane * LET C-11, a license-build var ...
that are shared by
C++03 C, or c, is the third letter in the Latin alphabet, used in the modern English alphabet, the alphabets of other western European languages and others worldwide. Its name in English is ''cee'' (pronounced ), plural ''cees''. History "C" ...
, enabling further compilation to a binary executable format by modern C and C++ compilers including gcc,
clang Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection ...
,
MinGW MinGW ("Minimalist GNU for Windows"), formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications. MinGW includes a port of the GNU Compiler Collection (GCC), GNU Binutils for Windows ...
, or
Microsoft Visual C++ Microsoft Visual C++ (MSVC) is a compiler for the C, C++ and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available in both tri ...
. It accepts Python code compatible with several different Python versions (currently supporting versions 2.6, 2.7, and 3.3–3.10) and optionally allows for the creation of standalone programs that do not require Python to be installed on the target computer. Nuitka was discussed at the 2012 EuroPython conference, and serious development began at the end of the same year. It now supports virtually all of the features of the Python language. Additional compile-time optimizations are planned for future releases, including avoiding the use of Python objects for additional variables whose type can be inferred at compile time, particularly when using iterators, which is expected to result in a large performance increase.


Limitations

Currently it is not possible to
cross-compile A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running. For example, a compiler that runs on a PC but generates code that runs on an Android smartphone is a cross ...
binaries (e.g. building the executable on Windows and shipping it to macOS). Standalone binaries built using the --standalone command line option include an embedded
CPython CPython is the reference implementation of the Python programming language. Written in C and Python, CPython is the default and most widely used implementation of the Python language. CPython can be defined as both an interpreter and a compi ...
interpreter to handle aspects of the language that are not determined when the program is compiled and must be interpreted at runtime, such as
duck typing Duck typing in computer programming is an application of the duck test—"If it walks like a duck and it quacks like a duck, then it must be a duck"—to determine whether an object can be used for a particular purpose. With nominative ty ...
,
exception handling In computing and computer programming, exception handling is the process of responding to the occurrence of ''exceptions'' – anomalous or exceptional conditions requiring special processing – during the execution of a program. In general, an ...
, and dynamic code execution (the eval function and exec function or statement), along with those Python and native libraries that are needed for execution, leading to rather large file sizes. Nuitka's design heavily relies on the internals of the CPython interpreter, and as a result other implementations of the Python language such as
PyPy PyPy () is an implementation of the Python programming language. PyPy often runs faster than the standard implementation CPython because PyPy uses a just-in-time compiler. Most Python code runs well on PyPy except for code that depends on CPyth ...
, Jython, and IronPython cannot be used instead of CPython for the runtime interpreter and library.


Usage

Nuitka can be installed from the repositories of many Linux distributions. It can also be installed through pip and pip3, respectively. Compilation is done either with nuitka program.py or with Python itself (python -m nuitka program.py).


References


External links

* * {{github, kayhayen/Nuitka - Source code and manual Source-to-source compilers Software using the Apache license Python (programming language) implementations