compiling to python byte codes
Robert Brewer
fumanchu at amor.org
Fri Sep 3 00:14:39 EDT 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
MIS
Amor Ministries
fumanchu at amor.org
More information about the Python-list
mailing list