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

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Sep 1 14:12:23 EDT 2007


Ivan Wang a écrit :
> On Sep 2, 9:45 pm, jwrweather... at gmail.com wrote:
> 
>>[snip code]
>>
>>Thanks for that. I realise that improving the algorithm will speed
>>things up. I wanted to know why my less than perfect algorithm was so
>>much slower in python than exactly the same algorithm in C. Even when
>>turning off gcc's optimiser with the -O0 flag, the C version is still
>>
>>
>>
>>
>>>100 times quicker.- Hide quoted text -
>>
>>- Show quoted text -
> 
> Maybe Python is  the slowest programming language in the world.
> So there is a joke: some python hater said that "python" can only
> crawl rather than run. :)
> 
> Python is slow because:
> (1) dynamic binding
Yes.
> (2) it is a interpretation language
Not quite. It's compiled to byte-code - just like Java (would you call 
Java an 'interpreted language' ?)



More information about the Python-list mailing list