New Python User Question about Python.

Paul Rubin phr-n2001 at nightsong.com
Thu Aug 23 17:56:53 EDT 2001


Skip Montanaro <skip at pobox.com> writes:
> One thing that everyone needs to remember is that optimizing any language is
> extremely hard.  Sprinkling a few static type declarations into your Python
> code isn't going to help much either.  Tim Peters spent a huge chunk of his
> professional career as a compiler/optimization expert.  He's been working in
> and around Python for about 10 years now, but he hasn't produced an
> optimizing compiler for Python yet.  (I keep waiting...)  I think there are
> (at least) two reasons: it's hard, and it's time-consuming.  Perhaps if we
> all scraped together our nickels and dimes and sent them to PythonLabs
> they'd be able to hire another person to do Tim's current job so he could
> spend the next year on such a project.

I wonder if it would be feasible to convert a Python syntax tree to a
Scheme S-expression, and then run the result through an existing
Scheme compiler like Orbit, or maybe a Lisp compiler like AKCL.


>     Chris> I had high hopes for the Py2C project, it seems like it had a LOT
>     Chris> of potential for allowing this, but it seems to be stalled out
> 
> There is a fundamental problem with Py2C: In many cases it gets you about a
> 2X speedup but generates huge object files.  It more-or-less unrolls the
> interpreter's main loop.  Also, since it operates at compile-time it can't
> tell what functions should be converted to C and what ones aren't worth the
> effort.  A runtime-based system could observe what functions are consuming
> the bulk of the time and just translate them.

KCL/AKCL compiles Lisp to C code in a pretty natural way.  It might be
a more reasonable approach.



More information about the Python-list mailing list