Steven D'Aprano wrote:
> Benjamin Peterson wrote:
>
>> Sammo <sammo2828 <at> gmail.com> writes:
>>
>>> String concatenation has been optimized since 2.3, so using += should
>>> be fairly fast.
>>
>> This is implementation dependent and shouldn't be relied upon.
>
> It's also a fairly simple optimization and really only applies to direct
> object access, not items or attributes.
>
>>>> Timer('s += "x"', 's = ""').repeat(number=100000)
> [0.067316055297851562, 0.063985109329223633, 0.066659212112426758]
Oops, sorry, I should have said... Timer is timeit.Timer.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list