Python is slow

James Mills prologic at shortcircuit.net.au
Tue Dec 16 17:47:32 EST 2008


n Wed, Dec 17, 2008 at 8:24 AM, r <rt8396 at gmail.com> wrote:
>> What kind of performance problem have you find in python that makes
>> you so unhappy?
>> What are you going to do with all the extra speed provided by c++ (a
>> Hello World! ?)...
>
> Still no reply from cm_gui, he must have googled "C hello world" :D

I must be mad for doing this - but I feel so strongly
about this topic. In 99.9% of cases generally things
are "feast enough"! So here goes:

jmills at atomant:~$ cat - > hello.c
int main (int argc, char ** argv) {
    printf("Hello World!\n!");
}
jmills at atomant:~$ tcc hello.c -o hello
jmills at atomant:~$ wc -l hello.c
3 hello.c
jmills at atomant:~$ ls -l hello.c
-rw-r--r-- 1 jmills jmills 69 2008-12-17 08:41 hello.c
jmills at atomant:~$ ls -l hello
-rwxr-xr-x 1 jmills jmills 2972 2008-12-17 08:41 hello

jmills at atomant:~$ time ./hello
Hello World!
!
real	0m0.003s
user	0m0.000s
sys	0m0.004s

jmills at atomant:~$ cat - > hello.py
print "Hello World!"

jmills at atomant:~$ time python hello.py
Hello World!

real	0m0.129s
user	0m0.016s
sys	0m0.020s

OMG OMG OMG! Python is slower!
If you compare "sys" times ~5x slower!

BUT ... This is in fact a misleading as most of
this is in the startup time. So let's be fairer:

jmills at atomant:~$ time python -E -S hello.py
Hello World!

real	0m0.011s
user	0m0.008s
sys	0m0.004s

Wow! Only ~2x as slow as C.

--JamesMills

PS: Yet another useless post!



More information about the Python-list mailing list