Towards faster Python implementations - theory

John Nagle nagle at animats.com
Tue May 8 23:25:38 EDT 2007


Marc 'BlackJack' Rintsch wrote:

> I don't see how this type inference for static types will work unless some
> of the dynamism of the language will get restricted.  But is this really
> necessary?  Isn't a JIT compiler and maybe type hinting good enough?

    Not necessarily.  One of the more powerful optimizations is to optimize
reference count updates.   Often, you can hoist reference count updates
out of loops, which is a big win.  But to do that, you need to be sure
that the code executed by the loop won't change unexpectedly.

    My point is that while all the dynamism in Python is occasionally
useful, most of the time for most of the variables most of it isn't
being used.  If we can discard the excess baggage, unnecessary
dictionary lookups, and unnecessary reference count updates a
large fraction of the time, it's a big win.  This requires
"surprise-free" language semantics, so that when something unusual
is going on, it's visibly reflected in the code.

    Surprise-free semantics also make code easier to debug.


					John Nagle



More information about the Python-list mailing list