[pypy-dev] Dynamic compilation via pyrex?

Grant Olson olsongt at verizon.net
Sun Mar 13 23:34:46 CET 2005


> We use Pyrex to statically compile dynamically generated
> source code. The compiled code is then imported into the
> process that generated the code.  But surely, this still means
> we are statically compiling things. 

Let me guess, this doesn't work on Windows yet? ;-)

> Let me note that with 'dynamic' we usually mean even more dynamic 
> than your pyasm, in that you could assemble and run inline fragments 
> of machine code at runtime (for implementing e.g. Psyco in PyPy). 

There is an api in pyasm that you can use to do this.  You don't need to
just pass in a monolithic string like I did in the example.  That was just
easier for most people to understand.  There is a little documentation on
this and it will be expanded in the next release.  I'm also toying with the
notion of something similar to a main() function that gets executed
automatically at runtime instead of forcing you to bind to function names
and calling the functions.

That is, unless you're talking about something like:

def foo(a,b):
    print a + b
    MOV EBX, [EBP-4]
    print EBX

That I can't do.  I would obviously have to fork CPython to implement
something like that, and that's not something I'm personally interested in.
I'm not even sure if this would make sense in an optimized build.

-Grant 




More information about the Pypy-dev mailing list