[Python-Dev] Optimized string concatenation

Nick Coghlan ncoghlan at iinet.net.au
Tue Aug 3 21:19:37 CEST 2004


Adam Souzis wrote:
> As someone relatively new to python, it struck me as a language wart
> that i had to learn the form '"".join() as the proper way to do string
> concatenation. It violates the principles of OOWTI and its certainly
> not the obvious way to do string concatenation. This patch does not
> cover all the cases so we're still stuck with join(), but as long as
> it is not a documentated "feature" it will harmlessly improve the
> performance of countless lines of code where the coder is either
> untrained or too lazy to use join().  If its documented it'd just
> muddy the waters vis a vis join(), besides the issues with other
> Python implementation mentioned here.

If I understand correctly, you're suggesting that ''.join(strings) 
continue to be the recommended, portable, non-quadratic method for 
concatenating strings.

And this patch be seen merely as a CPython optimisation for code which 
doesn't use the recommended string concatenation hack. . .

Seems like a sensible way of looking at it to me.

Cheers,
Nick.


-- 
Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268


More information about the Python-Dev mailing list