[pypy-dev] Objective of minimal python
David Roper
droper at lineone.net
Thu Jan 16 20:00:42 CET 2003
I've lurked on the periphery of the discussions so far and must admit to
being somewhat lost as to what exactly is being proposed. Am I correct in
believing the following?
1. That the objective of the project is to create a new implementation
python that:
i. Has a smaller memory footprint; and
ii. runs applications faster than the current interpreter; and
iii. is well suited to applications making significant use of lightweight
threads and continuations.
2. To achieve this it is intended to rewrite the 'front-end' of the Python
interpreter, specifically the language parser, lexical analyser and compiler
/ byte-code generator, in python itself.
3. The byte-code interpreter (is this the same as the virtual machine?) is a
program that reads the byte-code stream as data and processes it to do 'real
work'. In order to meet objective (iii), it is intended to write a new VM
that employs structure and mechanisms seen in the 'stackless'
implementation.
There are three possible implementations of the VM:
i. It could be written in 'C' and call the 'C' runtime library execute
functions implied by the byte-codes, e.g. allocation of space, arithmetic
functions etc. Such an approach could draw heavily upon the code base of the
'execution engine' (I don't know what it's really called) of the existing
VM.
ii. It could be written in any language (including, but not limited to,
'C') and convert the byte-code stream into 'C' (or, indeed, any other
statically compiled language), to be passed off to a compiler for
compilation, linking and subsequent execution. This advantage of this
approach is that it can exploit the considerable advances that compiler
writers have made in code optimisation. I presume that the reason that the
byte code, rather than python source code, is converted to 'C' is to be able
to reuse existing compiled classes for which one does not have access to the
source.
iii. I could emit machine specific assembly language instead of 'C'. If
understand correctly, this is what Psyco does. The advantage to this
approach is that the code emited can be modified as the execution of the
program (byte-code stream) evolves, thus permitting optimisations to be
performed that cannot be achieved in a statically compiled language. This
disadvantage is that it would be a very considerable effort generally to
produce assembly language that is as highly optimised as a good optimising
compiler might achieve.
I'd be most grateful for your comments.
Regards,
David Roper mailto:droper at lineone.net
More information about the Pypy-dev
mailing list