Assorted Questions regarding the future of Python...

skaller skaller at maxtal.com.au
Tue Nov 2 14:54:07 CET 1999


Alessandro Bottoni wrote:

> So, I wonder:
> 1) How about a Python compiler? Does anybody is working on such a project? I
> saw a lot of messages regarding this topic in the past, but which is the
> current status?

	I'm developing a full scale Python program compiler.
The current status is: the compiler works by first 'importing'
modules dynamically, then compiling the resulting dictionaries.
The 'importing' effectively requires a clone of Python, this part
of the compiler is called Viperi [Viper Interpreter]. It will be
available as a standalone tool, and the run-time it uses will
be part of the Ocaml back-end of the compiler.

	The interpreter now executes most Python correctly,
there are a few "not implemented" exceptions, and of course a few
bugs. Performance of the interpreter varies, but is currently
3-10 times slower than CPython (although some operations are actually
much faster than CPython, such as big numbers and loops, and some
are much slower ... ).

	I'm half way through implementing 'binding': freezing
names, and converting them to integers used to access arrays,
instead of dictionaries: CPython does this in functions, it is called
'fast loading'. Viperi 'fast loads' ALL names: whether they're 
function locals, module globals, or class and object attributes.

	[This feature speeds up pystone by about 15-25%]

	Here's what Viper will do: bind all names, merge all modules 
into a single 'address space' and replace A.B access with an access to
A_B. Inline function calls, removing substantial overhead. All these
features will be available in the interpreter, by using special
functions (such as 'bind_function(f)' which creates a bound version 
of a function).

	Now, we do type inference and ad hoc special case
pattern matching, seeking opportunites for optimisation.
Some of these features will be available in the interpreter.

	Finally, the resulting annotated syntax tree
is compiled into the target language: I am guessing
there will be two back ends: an Ocaml (native) back end,
for clients wanting a high power language to extend Python with,
and C, for clients desiring compatibility with CPython extensions.

	I hope to make an announcement soon (as soon as I have
it working well enough to execute 'Interscript'), seeking funding
from the Python and Ocaml communities and prospective clients.
If enough funding is forthcoming, the project will be 'Free for any
use',
otherwise it will have to be shareware or commercial.

> 2) How about a Python Virtual Machine, "a la Java", as a possible
> alternative to a real compiler? Is there anything like that? Is anybody
> working on it?

	The Python VM is an implementation dependent feature already
used by the Python bytecode system to execute bytecode.

-- 
John Skaller, mailto:skaller at maxtal.com.au
1/10 Toxteth Rd Glebe NSW 2037 Australia
homepage: http://www.maxtal.com.au/~skaller
downloads: http://www.triode.net.au/~skaller




More information about the Python-list mailing list