Nuitka Advanced Tour
Dear Python expert,
you know Python well, and you want to know what Nuitka is really doing, and how to get the most out of it. This tour gives you the short version, with pointers to the deep documentation. Nuitka is a source to source compiler. It translates your Python program into optimized C code, which is then compiled by your system’s C compiler and linked against On top of the translation, Nuitka applies a growing set of optimizations, including: Constant folding and propagation. Control flow optimizations. Type inference that replaces Python objects with native C types where it is provably safe. This is work in progress, with more coming in future releases. The result is usually a noticeable speedup over CPython, without changing the semantics of your program. You can compile whole programs rather than single files: For non-trivial projects, put the build configuration in Nuitka has a plugin system to support packages that need special handling, e.g. GUI toolkits. Plugins are automatically activated when Nuitka detects that their target package is used. Use Compile the whole program with Read Performance for what to expect and what to measure. The package configuration system can describe dependencies, data files, and Plugins can be written for your own packages. Nuitka Developer Manual explains the internals for contributors.How Nuitka works
libpython, so the resulting binary behaves exactly like CPython.anti-bloat work, which replaces slow or unnecessary modules, e.g. mock or test helpers, with fast dummy implementations. This is on by default.Controlling the Build
python -m nuitka --follow-imports program.py
nuitka-project: comment directives at the top of your main program, so that options, data files, and plugin settings are versioned with the source. See Nuitka User Manual for the syntax.Performance Tuning
--lto=yes for link time optimizations.--follow-imports.Extending Nuitka
anti-bloat rules for packages, see Nuitka Package Configuration.