[Python-Dev] PATCH submitted: Speed up + for string concatenation, now as fast as "".join(x) idiom

Nicko van Someren nicko at nicko.org
Thu Oct 5 22:29:28 CEST 2006

On 5 Oct 2006, at 20:28, Gregory P. Smith wrote:

>> I've never liked the "".join([]) idiom for string concatenation;  
>> in my
>> opinion it violates the principles "Beautiful is better than  
>> ugly." and
>> "There should be one-- and preferably only one --obvious way to do  
>> it.".
>> (And perhaps several others.)  To that end I've submitted patch  
>> #1569040
>> to SourceForge:
>> http://sourceforge.net/tracker/index.php? 
>> func=detail&aid=1569040&group_id=5470&atid=305470
>> This patch speeds up using + for string concatenation.
> yay!  i'm glad to see this.  i hate the "".join syntax.

Here here.  Being able to write what you mean and have the language  
get decent performance none the less seems to me to be a "good thing".

> have you run any generic benchmarks such as pystone to get a better
> idea of what the net effect on "typical" python code is?

Yeah, "real world" performance testing is always important with  
anything that uses lazy evaluation.  If you get to control if and  
when the computation actually happens you have even more scope than  
usual for getting the benchmark answer you want to see!


More information about the Python-Dev mailing list