macbe
macbe

Reputation: 169

How does cx_freeze compile a Python script?

Does cx_freeze contain its own compiler that goes from Python -> binary? Or does it translate it (e.g. to C), and compile the translated code?

Edit: It appears to be compiled to byte-code. So does this mean a cx_freeze exe is just the byte-code -> binary part of the Python interpreter?

Upvotes: 4

Views: 316

Answers (1)

Thomas K
Thomas K

Reputation: 40340

cx_Freeze doesn't really compile your code. It really just packages up your Python code along with the Python interpreter, so that when you launch your application, it sets up a Python interpreter and starts running your Python code. It has the necessary machinery to run from either Python source code or bytecode, but it mostly stores modules as bytecode, because that's quicker to load.

Options like Cython and Nuitka go a step further - they translate your code to C and compile it to machine code, but they still use the Python VM machinery. It's just compiled code calling Python functionality rather than the VM running Python bytecode.

Upvotes: 2

Related Questions