Joining strings versus augmented assignment

Skip Montanaro skip at pobox.com
Fri Jan 31 08:48:34 EST 2003


    Andy> In his Linux Journal piece on Quixote
    Andy> (http://www.linuxjournal.com/article.php?sid=6178) Greg Ward
    Andy> mentions that when joining a series of strings together it is more
    Andy> efficient to use "".join(listOfStrings) rather than += (augmented
    Andy> assignment).

Augmented assignment:

    s += t

amounts to nothing more than 

    s = s + t

Once that equivalence is established, you can refer to the somewhat
outdated, but still germane:

    http://manatee.mojam.com/~skip/python/fastpython.html#stringcat

for the remaining details.

Skip





More information about the Python-list mailing list