View Single Post
Old Dec 7th, 2005, 3:25 PM   #4
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Python is open-source because the C source-code for the Python interpreter is open for anyone to read or adapt (if I recall, it has a BSD-like license). The reason that Python doesn't produce natively compiled programs is an another matter entirely; one that has technical, rather than legal, reasons.

Normally, Python takes a .py file and converts it into Python bytecode, which it then runs. In the case of imported modules, it caches this bytecode in .pyc files, so files don't need to be interpreted from scratch everytime they're run. As well as .py and .pyc files, there are .pyd files, which are actually just standard windows DLLs that have the Python C API, and .pyo files, which are standard Linux so libraries. There's probably something similar for Macs.

I don't know how Py2exe works, but I do know that for each .py file in my program, py2exe created a matching .pyd file. I suspect what occurs is that py2exe generates the pyc bytecode for each .py file, and then does some binary magic which embeds this into a .pyd.

Suffice to say, it works, and no source is required.
Arevos is offline   Reply With Quote