[Python-Dev] Usage of += on strings in loops in stdlib

Steven D'Aprano steve at pearwood.info
Thu Feb 14 01:25:58 CET 2013


On 14/02/13 01:18, Chris Withers wrote:
> On 13/02/2013 11:53, Steven D'Aprano wrote:
>>> I fixed a performance bug in httplib some years ago by doing the exact
>>> opposite; += -> ''.join(). In that case, it changed downloading a file
>>> from 20 minutes to 3 seconds. That was likely on Python 2.5.
>>
>>
>> I remember it well.
>>
>> http://mail.python.org/pipermail/python-dev/2009-August/091125.html
>>
>> I frequently link to this thread as an example of just how bad repeated
>> string concatenation can be, how painful it can be to debug, and how
>> even when the optimization is fast on one system, it may fail and be
>> slow on another system.
>
> Amusing is that http://mail.python.org/pipermail/python-dev/2009-August/thread.html#91125 doesn't even list the email where I found the problem...

That's because it wasn't solved until the following month.

http://mail.python.org/pipermail/python-dev/2009-September/thread.html#91581



-- 
Steven


More information about the Python-Dev mailing list