Speed of string += string

Mads Orbesen Troest mads at troest.NEVERMORE.dk
Sat Apr 12 19:19:29 CEST 2003


Given that strings are immutable, is it exceedingly slow (and memory 
spiking) to do a lot of "string += string" operations in one's code? IOW, 
does each and every += evaluation lead to a new concatenated copy of the 
previous string (now freed for garbage collection) and the new string, so 
that the longer the string to which stuff is appended is, the longer times 
each += operation takes?

   /\/\\ads Orbesen Troest

More information about the Python-list mailing list