Why is this loop heavy code so slow in Python? Possible Project Euler spoilers

Diez B. Roggisch deets at nospam.web.de
Sun Sep 2 18:29:01 EDT 2007


Wildemar Wildenburger schrieb:
> Martin v. Löwis wrote:
>>>> (2) it is a interpretation language
>>> Not quite. It's compiled to byte-code - just like Java (would you call
>>> Java an 'interpreted language' ?)
>>
>> Python is not implemented like Java. In Java (at least in HotSpot),
>> the byte code is further compiled to machine code before execution;
>> in Python, the byte code is interpreted.
>>
> OK, good. Naive question now comming to mind: Why doesn't Python do the 
> latter as well?

because of the dynamic nature of it. Java is statically typed, so the 
JIT can heavily optimize.

OTH psyco IS a JIT-compiler to optimize certain calculations which are 
mostly of a numerical nature. But this can't be done to the extend it is 
possible in java.

Diez



More information about the Python-list mailing list