-
-
Notifications
You must be signed in to change notification settings - Fork 36
python compiler
Python is treated the same way we treat the other compilers. With one big particularity. Python can be:
- Interpreted
- Compiled to machine code
- Compiled to bytecode
In this section I will describe how we do it internally.
This is how you would normally run a python program:
# Internally we do
python main.py
We use nuitka to compile the program to machine code. What nuitka does, is to convert your code to C and compile it. This means your program can run even if the computer doesn't have a python interpreter. This way of compiling offers the maximum performance.
# Internally we do
nuitka main.py
The way of running the resulting program is just
./bin/program
We use the tool pythoninstall
to convert the program to bytecode. This means your program can run in any machine that has the python interpreter, with a performance close to machine code. This way of compiling offers a portability as good as interpreted python, with a performance close to machine code. (Similar to a java/C# program).
# Internally we do
pyinstaller main.py
Again, the way of running the resulting program is just:
./bin/program
Note that if you pass parameters in your .solution
file, you are targeting only one type of compilation (as every type of compilation use a different compiler). If you want to do crazy stuff like performing all types of compilation at the same time, fork the project and write your own python backend.