Python compilers?

Heather Coppersmith me at privacy.net
Sat May 22 09:13:39 EDT 2004


On Sat, 22 May 2004 05:54:24 GMT,
Carl Banks <imbosol at aerojockey.invalid> wrote:

> ... There's two questions remaining for me:

> 1. These claims that Lisp code can approach 50 percent the speed
>    of C, is that with or without the optional type declarations?

That would be *with* type declarations.

> 2. If you don't use the declarations, does compiling Lisp help?
>    If it does (and nothing I've read indicated that is doesn't),
>    it definitely casts some doubt on the claim that compiling
>    Python wouldn't help.  That's kind of been my point all
>    along.

In _Common Lisp The Language, Second Edition_, by Guy Steele
(CLTL2), on page 686, in section 25.1.3 ("Compilation
Environment") there is a lengthy list of assumptions the compiler
makes, including:

    o ... within a named function, a recursive call to a function
      of the same name refers to the same function [barring
      notinline declarations] ...

    o ... a call within the file being compiled to a named
      function that is defined in that file refers to that
      function [barring notinline declarations] ...

    o ... the signature (or "interface contract") of all built-in
      Common Lisp functions will not change ...

    o ... the signature (or "interface contract") of functions
      with ftype information will not change.

    o ... any type definition made with defstruct or deftype in
      the compile-type environment will retain the same definition
      in the run-time environment.  It may also assume that a
      class defined in the compile-time environment will be
      defined in the same run-time environment in such a way as to
      have the same superclasses and metaclass ...

    o ... if type declarations are present in the compile-time
      environment, the corresponding variables and functions
      present in the run-time environment will actually be of
      those types ...

So compiled Lisp is a less dynamic than Python, and the built-in
functionality is large and guaranteed to match its textbook
definitions, which gives Lisp Compilers more than a fighting
chance.  I'm pretty sure I've seen that summary on c.l.p before.

> I think (and I'm wrapping this up, cause I think I made my
> point) compiling Python could help, even without type
> declarations, but probably not as much as in Lisp.  It could
> still make inferences or educated guesses, like Lisp compilers
> do; just maybe not as often.

I agreem, with emphasis on "could" and some hesitation on how much
guessing I want my compiler to do.

Regards,
Heather

-- 
Heather Coppersmith
That's not right; that's not even wrong. -- Wolfgang Pauli



More information about the Python-list mailing list