Python compilation

From wikinotes

pyc files

pyc can be easily compiled or reverse-compiled.

python -m compileall -d "" /src/code_rootdir         # compile (-d hides orig path in tracebacks)
find /src/code_rootdir -name '*.py' -exec rm {} \;   # delete .py files


I haven't had the opportunity to play with this yet, but pypy is supposed to be blindingly fast. Something to look out for.


Cython expresses your python code as C/C++ code, then you use a compiler to compile it into a finished product. It boasts nearly 100% compatibility with python, and enables you to do further optimizations with static typing.

See python cython .


The go-to low-level python freezing solution. Create standalones on linux, mac, windows for that operating system.

See python cx_freeze .


PyOxidizer is meant to create single file python executables. Supports mac, windows, linux.

See python pyoxidizer.


bbfreeze is another compiler, but it's advantage is that it compiles to a format that runs on window,osx, AND linux.

bbfreeze is no longer maintained


Compile python into executables on windows. currently python2.7 only.

See python py2exe.


A completely cross platform compiler. (Meaning it compiles linux binaries on linux, osx binaries on osx, windows binaries in windows). It prides itself on it's simplicity. I should look into this as a simpler alternative.