I like the idea. In fact, after reading the psyco website, I started something like it myself in October. The answer to the question that is on everybody's minds? PyPython. (I envisioned it as potentially being the springboard for other versions: AdaPython, LispPython, etc.) Additionally, the goal was to make a clear and readable implementation of Python which people could study and play with, without requiring them to know C. My plan was "simply" to take the CPython code and convert it into Python code, minimizing the use of "high level" features like lambda, generators, etc., so that a small core could easily be hand compiled into the language du jour. Eventually, a reduced dialect of Python might be employed for the core (interpreter loop and basic objects) such that a simple compiler could be built for it. My greatest ally was my biggest enemy. To make things easier in development, I used close association of my program with the host system. This way I could defer converting the compiler and core objects untill later. Unfortunately, it was *extremely* unclear where PyPython ended and the host system began. In my final incarnation, the PyPython objects with external visibility were referenced from a global definition file (a'la python.h), where they were simply imported wholesale from __builtins__. But the problem which stymied me was the issue of what to do with Exceptions. I discarded the concept of copying the "return Null" technique of CPython - having to check every return value for an error condition seems so unpythonic. But raising native exceptions has the complication of discriminating between exceptions in the host system (or rather the PyPython code) and the end user interpreted code. I might have been able to do something with it if I could have created my own traceback objects from within Python. (That was my greatest frustration - the inability to create and modify core objects [frame, thread, traceback, etc.] from within python itself.) That's where I left it in December when I stopped for Christmas. (Don't bother to ask for code: most of what I wrote was dead ends or "mindless conversion" from C.) I agree with using cross compilers in the bootstrap proceedure and with being "stackless" - two features I was going to apply. One additional thing that came about as a direct result of Python's lack of a switch statement: I replaced the switch statement with an array of references to functions implementing the opcodes. (I was going for clarity over speed) One offshoot of this is the potential to have multiple opcode schemes in the same interpreter. (Like Python 1.5.2 and Python 2.2 - or better yet, Python and Java) How does that work with parameter/return value passing and potential psyco optimization? Don't know - didn't get that far. I might not make the sprint, but I'd be glad to help as I can, Rocco Moretti P.S. I would advise for some brave soul (more reliable than me) to start summaries of pypy-dev, like has been done recently for python-dev. It would be nice to have a record of all the major design considerations in a location which doesn't require several hours of sorting through fluff. __________________________________________________________________ The NEW Netscape 7.0 browser is now available. Upgrade now! http://channels.netscape.com/ns/browsers/download.jsp Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/
Rocco Moretti wrote: ...
My plan was "simply" to take the CPython code and convert it into Python code, minimizing the use of "high level" features like lambda, generators, etc., so that a small core could easily be hand compiled into the language du jour. Eventually, a reduced dialect of Python might be employed for the core (interpreter loop and basic objects) such that a simple compiler could be built for it.
Very true. ...
Unfortunately, it was *extremely* unclear where PyPython ended and the host system began. In my final incarnation, the PyPython objects with external visibility were referenced from a global definition file (a'la python.h), where they were simply imported wholesale from __builtins__.
It is one of my fears when rewriting Python in Python: How often will I fail to recognize in which system I am? There was a two-part TV film like "world at the wire" in Germany, late 70's, where the level of simulation also was not always clear :-)
But the problem which stymied me was the issue of what to do with Exceptions. I discarded the concept of copying the "return Null" technique of CPython - having to check every return value for an error condition seems so unpythonic.
It does seem so if you have to write that crap by hand. When generating code, this is no issue at all. I wasn't sure for myself about this problem. Then I read Armin's long reply to everything, and I found one thing of his generated-c-approach appealing: Everything is turned back into generated C, and there is no question about exceptions: Surely they would be built like before. Now, why do we have a problem with it in an interpiler that does not create C code? I think we do lack experience. ...
I agree with using cross compilers in the bootstrap proceedure and with being "stackless" - two features I was going to apply. One additional thing that came about as a direct result of Python's lack of a switch statement: I replaced the switch statement with an array of references to functions implementing the opcodes.
This is most natural if you don't have a case construct. If I ever whished to add such a thing, then for this project :-)
(I was > going for clarity over speed) One offshoot of this is the potential to have multiple opcode schemes in the same interpreter. (Like Python 1.5.2 and Python 2.2 - or better yet, Python and Java)
Absolutely, this can be done if it makes enough sense.
How does that work with parameter/return value passing and potential psyco optimization? Don't know - didn't get that far.
After Armin's recent post, it seems to be true that Psyco will get a complete rewrite, with a whole lot of new ideas. Armin seems to be eager to try different object layouts as well, with/without refcounts, with classical GC, ..., so I believe the new, Python-based Pysco will be very capable.
I might not make the sprint, but I'd be glad to help as I can, Rocco Moretti
There will be a second sprint, right before EuroPython. At least, Guido proposed that, probably enough to make it doubtlessly happen. ciao - chris
Hello Christian, hello Rocco, Nice to hear about your project! On Fri, Jan 17, 2003 at 02:46:10AM +0100, Christian Tismer wrote:
[...exceptions...] and I found one thing of his generated-c-approach appealing: Everything is turned back into generated C, and there is no question about exceptions: Surely they would be built like before.
Yes. I think that a good way to know the limit between the levels is, at first, by closely following the original C code --- but in essence only; constructions like the "return NULL" thing must clearly be ruled out, and replaced by higher-level Python constructs. Just as we are thinking about a "PyObject" base class for all Python objects, we should define an "EPython" exception that we can throw to signal a Python-visible exception, with whatever Python-visible exception we want being specified as attributes in the EPython instance. The EPython exception is caught in the main loop of the interpreter, at the point where CPython catches the cascade of "return NULLs". We can then generate CPython-like C code by adding NULL tests everywhere, or try alternatives (e.g. use the ANSI C setjmp()/longjmp() functions). There are lots of other variations on this theme. It would be possible and probably easy to generate Continuation-Passing-Style C code for the whole interpreter core, i.e. recreate Christian's old Stackless implementation for free. I guess that's something he has already considered :-) This can be done without having to write MiniPy in any special style in the first place. A bientot, Armin.
Armin Rigo wrote: ...
There are lots of other variations on this theme. It would be possible and probably easy to generate Continuation-Passing-Style C code for the whole interpreter core, i.e. recreate Christian's old Stackless implementation for free. I guess that's something he has already considered :-) This can be done without having to write MiniPy in any special style in the first place.
Guess what: The only thing I could love more than Stackless is to get rid of it, due to this project. A bientot, Christian -- Christian Tismer :^) <mailto:tismer@tismer.com> Mission Impossible 5oftware : 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 89 09 53 34 home +49 30 802 86 56 pager +49 173 24 18 776 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)
-
Armin Rigo -
Christian Tismer -
roccomoretti@netscape.net