Python is horribly slow compared to bash!!

wxjmfauth at gmail.com wxjmfauth at gmail.com
Thu May 22 09:43:46 EDT 2014


Le jeudi 22 mai 2014 12:54:22 UTC+2, Chris Angelico a écrit :
> Figure some of you folks might enjoy this. Look how horrible Python
> 
> performance is!
> 
> 
> 
> http://thedailywtf.com/Articles/Best-of-Email-Brains,-Security,-Robots,-and-a-Risky-Click.aspx
> 
> 
> 
> Actually, probably a lot of you folks already read TDWTF, but maybe
> 
> some don't (yet).
> 
> 
> 
> ChrisA

=========
=========

>>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = 'z'")
[1.4027834829454946, 1.38714224331963, 1.3822586635296261]
>>> timeit.repeat("(x*1000 + y)[:-1]", setup="x = 'abc'; y = '\u0fce'")
[5.462776291480395, 5.4479432055423445, 5.447874284053398]

Na, na, na, I win.

But that's peanuts.

I can make an application running 100 times slower just
by replacing 'z' with Dutch characters. [*]. I win again.

I can take the same application and replace 'z' by ..., and
... No, I do not win :-( . Python fails.


[*] Unicode is fascinating, working with it is a little
bit travelling.

jmf




More information about the Python-list mailing list