Jump to content

Nuitka

From Wikipedia, the free encyclopedia
Nuitka
Developer(s)Kay Hayen and others
Stable release
2.4.2[1] / 23 July 2024;2 months ago(2024-07-23)
Repositorygithub.com/Nuitka/Nuitka
Written inC,Python
Available inEnglish
Typesource-to-source compiler
LicenseApache License2.0
Websitenuitka.net

Nuitka(pronounced as/njuːtkʌ/[2]) is asource-to-source compilerwhich compilesPythoncode toCsource code, applying some compile-time optimizations in the process such asconstant folding and propagation,built-in call prediction,type inference,and conditional statement execution.[3][4]Nuitka initially was designed to produce C++ code, but current versions produce C source code using only those features ofC11that are shared byC++03,enabling further compilation to a binary executable format by modern C and C++ compilers includinggcc,clang,MinGW,orMicrosoft Visual C++.It accepts Python code compatible with several different Python versions (currently supporting versions 2.6, 2.7, and 3.3–3.12) 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.[5]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.[6]

Limitations

[edit]

Currently it is not possible tocross-compilebinaries (e.g. building the executable on Windows and shipping it to macOS).

Standalone binaries built using the--standalonecommand line option include an embeddedCPythoninterpreter to handle aspects of the language that are not determined when the program is compiled and must be interpreted at runtime, such asduck typing,exception handling,and dynamic code execution (theevalfunction andexecfunction 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 asPyPy,Jython,andIronPythoncannot be used instead of CPython for the runtime interpreter and library.[3]

Usage

[edit]

Nuitka can be installed from the repositories of many Linux distributions. It can also be installed throughpipandpip3,respectively. Compilation is done either withnuitka program.pyor by calling Python itself and afterwards defining which module to run, which in this case is Nuitka (python -m nuitka program.py).

References

[edit]
  1. ^"Nuitka Releases".
  2. ^Nuitka the python compiler,retrieved2022-03-02
  3. ^abHayen, Kay (2012-06-21)."User Manual".Nuitka Home.Retrieved2020-05-14.
  4. ^Yegulalp, Serdar (2018-10-02)."Nuitka Python-to-C compiler readies big performance gains".InfoWorld.Retrieved2020-05-14.
  5. ^Yegulalp, Serdar (2014-12-19)."Python-to-C++ compiler promises speedier execution".InfoWorld.Retrieved2020-05-14.
  6. ^"Nuitka Changelog".GitHub.2020-05-10.Retrieved2020-05-14.
[edit]