translating Python to Assembler

Chris Mellon arkanes at gmail.com
Fri Jan 25 22:33:22 EST 2008


On Jan 25, 2008 9:09 PM, Steven D'Aprano
<steve at remove-this-cybersource.com.au> wrote:
> On Wed, 23 Jan 2008 08:49:20 +0100, Christian Heimes wrote:
>
> > It's even
> > possible to write code with Python assembly and compile the Python
> > assembly into byte code.
>
> Really? How do you do that?
>
> I thought it might be compile(), but apparently not.
>

There are tools for it in the undocumented compiler.pyassem module.
You have to pretty much know what you're doing already to use it - I
spent a fun (but unproductive) week figuring out how to use it and
generated customized bytecode for certain list comps. Malformed
hand-generated bytecode stuffed into code objects is one of the few
ways I know of to crash the interpreter without resorting to calling C
code, too.



More information about the Python-list mailing list