String concatenation performance

Ben Sizer kylotan at gmail.com
Thu May 11 11:32:03 EDT 2006


Cristian.Codorean wrote:
> I was just reading a "Python Speed/Performance Tips" article on the
> Python wiki
> http://wiki.python.org/moin/PythonSpeed/PerformanceTips
> and I got to the part that talks about string concatenation and that it
> is faster when using join instead of += because of strings being
> immutable.

The idea is that you call join() once rather than calling += many
times. You achieve this by placing all the strings you want
concatenating into a single list, not by calling join() with multiple
lists.

-- 
Ben Sizer




More information about the Python-list mailing list