mix statically typed with dynamically typed

John Nagle nagle at animats.com
Fri Jan 29 09:50:18 CET 2010


Yingjie Lan wrote:
> We all know that Python is dynamically typed, and dynamically typed languages
> are generally slower than statically typed ones. 

    That's mostly a problem with the CPython interpreter, which is a naive
interpreter.  Many dynamically typed languages have implementations which
optimize out much of the run-time type handling.  Shed Skin does this
for Python.  LISP has been doing this better for decades.  The JIT
systems for Javascript also do this.

    Psyco has some explicit typing capability, but it doesn't do much about
eliminating redundant attribute lookups.

    The two big wins that Python needs for performance are 1) at least
recognize when a variable can be represented as "long" "double", or
"char", and 2) recognize when an object or module doesn't need dynamic
attribute lookup and the attribute slots can be nailed down at compile
time.

    (Plus, of course, something so that multithreaded programs don't
suck so bad on multicore CPUs.)

				John Nagle




More information about the Python-list mailing list