compiling to python byte codes

Robert Brewer fumanchu at
Fri Sep 3 06:14:39 CEST 2004

Leif K-Brooks wrote:
> Jason Lai wrote:
> [talking about compiling some language besides Python to 
> Python bytecode]
> > What about generating an Abstract Syntax Tree 
> (compiler.ast) and using 
> > the compiler module (compiler.pycodegen) to write the bytecode?
> That would certainly be possible, but it seems to me like it might be 
> easier to generate Python code. You're using Python logic if 
> you use its AST, after all.

In my limited experience, using compiler.ast ends up being *very* slow
due to all of the tuple packing and unpacking. On the other hand, I
personally find high-level code-generation to be a rat's nest better
left unexplored. I'd recommend the OP just write a prototype MA-compiler
and MA-interpreter (in Python), shake out the design issues, then move
it to C _if_ it's too slow.

My 2 cents,

Robert Brewer
Amor Ministries
fumanchu at

More information about the Python-list mailing list