Python questions -> compiler and datatypes etc

brueckd at tbye.com brueckd at tbye.com
Thu Oct 11 00:32:07 EDT 2001


On 10 Oct 2001, Paul Rubin wrote:

> Richard Jones <richard at bizarsoftware.com.au> writes:
> > Do a search in the python mailing list for "python compiler". The
> > answer is invariably "it's bloody hard". This stems from the
> > fundamental dynamic typing of python. It's very very very hard to
> > write a compiler when you don't know the type of the objects you're
> > dealing with beforehand. Java knows these types, because it's
> > statically typed. Therefore it's relatively trivial (compared to
> > python) to write a compiler for Java.
>
> I think the real answer to why there's no Python compiler is no one
> has really wanted to write one.  Python's runtime semantics are pretty
> similar to Lisp systems, and native-code Lisp compilers have existed
> since the 1960's or maybe even earlier.  It might even be feasible
> to adapt one to compile Python.

That'd be great. How about just creating a Python-to-Lisp translator? Then
you could use whatever Lisp compilation tools are available (assuming, of
course, that the performance of compiled Lisp is good enough to make the
effort worthwhile).

It seems like the really hard part about translating Python to C, for
example, is that you're moving "down" the dynamic language scale. But if
you already have a compiler for a language that is near or higher on that
scale, then somebody has already done a lot of the work for you.

-Dave





More information about the Python-list mailing list