compiling to python byte codes

"Martin v. Löwis" martin at v.loewis.de
Thu Sep 2 19:59:08 CEST 2004


Michael Foord wrote:
> But that still doesn't answer the OPs question which is about writing
> code in another language to generate python bytecode....

I did. I told him about the compile() function, and indeed,

compile("2+4","<string>","eval")

generates Python bytecode.

> Is python bytecode *that* different to Java bytecode (not in detail
> but in concept ?).

Yes. Java bytecode is typed; Python bytecode is not.

> There's no reason why another compiler couldn't
> emit python bytecode to run on the 'python virtual machine' ?

It is certainly possible. Indeed, the Python compiler does generate
Python bytecode from source code, so it must be possible :-)

Regards,
Martin




More information about the Python-list mailing list