[pypy-dev] psyco in Python was: Minimal Python project

Edward K. Ream edream at tds.net
Tue Jan 14 16:24:10 CET 2003

> > What happens if these goals conflict?  For example, much of psyco is
> > presently written in C.  I don't suppose these goals imply that all
> > of psyco will be recast in Python, or do they?
> I believe that's the plan anyway, somewhat because coding in Python is
> less painful than coding in C.  Have you *looked* at the source to
> psyco?  It's, umm, challenging.

Yes, I've looked carefully at the code and converted it to a Leo outline.
It is indeed challenging, as is the code for any compiler.  However, the
reason it is challenging is not particularly that it is written in C, but
that neither the documentation nor the code comments explain completely
_what_ the code is trying to accomplish and the _context_ in which the code
operates.  This is often true for other compilers, like gcc which I have
also studied.  The difference is that gcc uses completely standard compiling
techniques while psyco does not.  That's not a knock against psyco!

Also, it is not clear to me exactly how psyco in Python would work in the
production version.  Clearly, it would be easy to do psyco in Python using
the _present_ C implementation of Python, but how would psyco in Python be
bootstrapped in an "all-Python" version?  At present, all Python code
eventually gets executed as C code: either in the interpreter itself or in
the C libraries.  In an "all-python version everything would get executed
either as C code in the libraries, or assembly language output by Psycho.
The question is, how does the Python code that represents psyco get "turned
into" either C or assembly language?  Do you see the problem?  My guess is
that for the production "all-python" version it would be easiest, in fact,
to use something very similar to the present C version of psyco.  Can anyone
suggest an easier way?

Doing psyco in Python for experimental purposes is a great idea.  I just
don't see how to implement psyco in Python in a production package without
using the C interpreter as a bootstrap!  And yes, I suspect that a C
language version of psyco will be faster than psyco in Python.

Edward K. Ream   email:  edream at tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html

More information about the Pypy-dev mailing list