compiling to python byte codes
"Martin v. Löwis"
martin at v.loewis.de
Thu Sep 2 08:21:40 CEST 2004
Maurice LING wrote:
> I remembered reading a MSc thesis about compiling Perl to Java bytecodes
> (as in java class files).
You don't have to look that far. Jython compiles Python code into Java
bytecode; IronPython compiles Python code into Microsoft intermediate
> I'm wondering if
> something of such had been attempted in python, as in compiling X
> language into .pyc.
The easiest way to create a .pyc file is to create a Python file,
and then compile that. There are various tools that compile X to
.pyc. For example, Fnorb compiles OMG IDL into .pyc files.
> I do not understand the schematics of .pyc files but
> I assume that they are the so called python bytecode files.
> Or is there any documentation or books that is the python equivalent of
> "Programming for the Java Virtual Machine" by Joshua Engel?
There is the dis module and its documentation. However, as I said, in
Python, you don't really *need* to create .pyc files directly, as
the Python compiler is always available through the compile() builtin
function. This is unlike Java or .NET, where the compiler is not
available in the JRE, or the .NET commercial framework.
More information about the Python-list