Python compiler

Programming, for all ages and all languages.
Post Reply
Aleksander Helgake

Python compiler

Post by Aleksander Helgake »

Can you compile python code or do you have to distribute the py files and tell people to use an intepreter?
Nychold

Re:Python compiler

Post by Nychold »

Generally speaking, Python is a scripting language, meaning it is interpreted from the source code. A compiled language (like C or Pascal) is compiled down to machine code for a specific machine. Other languages like Java act as both: they are compiled into a special byte-code which is later interpreted by a program called a Virtual Machine.

I don't know of any Python compiler, but that doesn't mean one doesn't exist. If one does exist, you could certainly use that rather than the standard Python tools, which would mean your Python code would run on one and only one system; in the case of a VM, perhaps on many systems, but with unreadable code.
chris

Re:Python compiler

Post by chris »

I think what you want is a Frozen Binary. Frozen Binary executables are packages that combine your script's byte code and the Python interpreter into a single executable program. With these, scripts can be launched in the same ways that you would launch any other executable program.

Try here: http://sourceforge.net/projects/py2exe/

Btw, you can also distribute your script in the byte code format (.pyc) if you don't want others to use/read your source.
Post Reply