Python speed-up

Skip Montanaro skip at pobox.com
Wed Sep 22 21:49:32 CEST 2004


    gerrit> Why isn't cStringIO faster than concatenating strings?

    gerrit> Using python2.4:
    ...

Because in 2.4 common case string concatenation gets a big speed boost:

    % python2.3 ~/local/bin/timeit.py  -s 's=""' "s+='foo'"
    10000 loops, best of 3: 68.3 usec per loop
    % python2.4 ~/local/bin/timeit.py  -s 's=""' "s+='foo'"
    1000000 loops, best of 3: 0.855 usec per loop

Skip



More information about the Python-list mailing list