Python compilers?

Paul Rubin http
Thu May 20 04:40:40 EDT 2004


Carl Banks <imbosol at aerojockey.invalid> writes:
> > The example above kills any attempt to turn a.bar() into a static
> > procedure call.
> 
> Of course it does--but it's one method.  A compiler, if it's good,
> would only make the optization on methods named "bar", and it could
> probably pare the number of possible classes it could happen to down
> to only a few.

How could it possibly know?  The reassignment of a.bar could happen
anytime, anywhere in the code.  Maybe even in an eval.

> I mean you could have a Turing nightmare on your hands, with all kinds
> of crazy setattrs and execs and stuff, in both Python and Lisp, and
> then there's not much a compiler could do but emit totally general
> code.  I assume Lisp compilers do this sometimes.

Lisp compilers might have to do that sometimes, but Python compilers
would have to do it ALL the time.  Psyco took one way out, basically
generating code at runtime and caching it for specific operand types,
but the result is considerable code expansion compared to precompilation.



More information about the Python-list mailing list