
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

"Grant Olson" <olsongt@verizon.net> writes:
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? ;-)
No, it does. We have Christian to beat us up when we break that :)
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.
Uh, no, neither of these things. The way psyco works is that when "compiling" a function like: def f(a): return 1 + 2 + a it only compiles as far as it can until it needs to know the type of a; then it stops and "waits" until the function is actually called, when obviously this is an easy question to answer, then compiles a bit more, and so on. If the function is called again with a different type of argument, a different version of the code is compiled. Etc. People don't generally expect this sort of thing when they design their APIs :) Cheers, mwh -- What the semicolon's anxious supporters fret about is the tendency of contemporary writers to use a dash instead of a semicolon and thus precipitate the end of the world. -- Lynne Truss, "Eats, Shoots & Leaves"

Grant Olson wrote:
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? ;-)
It doeswork on Windows. (And I seem to be the only one in the PyPy team who runs it on Windows, so I'm responsible) ...
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.
I will take a closer look at pyasm very soon! cheers - chris -- Christian Tismer :^) <mailto:tismer@stackless.com> tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/
participants (3)
-
Christian Tismer
-
Grant Olson
-
Michael Hudson