[Python-Dev] PATCH submitted: Speed up + for string concatenation, now as fast as "".join(x) idiom

skip at pobox.com skip at pobox.com
Sat Oct 7 13:53:43 CEST 2006


    Fredrik> Nicko van Someren wrote:
    >> If it speeds up pystone by 5.5% with such minimal down side I'm hard
    >> pressed to see a reason not to use it.

    Fredrik> can you tell me where exactly "pystone" does string
    Fredrik> concatenations?

I wondered about that as well.  While I'm not prepared to assert without a
doubt that pystone does no simpleminded string concatenation, a couple
minutes scanning the pystone source didn't turn up any.  If the pystone
speedup isn't an artifact, the absence of string concatention in pystone
suggests it's happening somewhere in the interpreter.

I applied the patch, ran the interpreter under gdb with a breakpoint set in
string_concat where the PyStringConcatenationObject is created, then ran
pystone.  The first hit was in

    site.py -> distutils/util.py -> string.py

All told, there were only 22 hits, none for very long strings, so that
doesn't explain the performance improvement.

BTW, on my Mac (OSX 10.4.8) max() is not defined.  I had to add a macro
definition to string_concat.

Skip



More information about the Python-Dev mailing list