Re:Efficient String Concatenation in Python
by pdonis on Sunday September 08, 2013 @12:48PM
(#6349283)
using xrange made it slightly faster
That's what I would expect, since xrange works like a generator; but the internals of its implementation in CPython back when the article ran its original tests were evidently less efficient than they are now.
the difference was pretty small
I suspect that's because the strings being concatenated are really small (the largest will only be 5 bytes for n=10000). I would expect the difference to get bigger as the individual strings get larger.
(Here I'm using the stock Python 2.7.1 on a 2011 MacBook Pro.)