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

Nicko van Someren nicko at nicko.org
Sun Oct 8 01:01:11 CEST 2006

On 7 Oct 2006, at 09:17, Fredrik Lundh wrote:

> Nicko van Someren wrote:
>> If it speeds up pystone by 5.5% with such minimal down side
>> I'm hard pressed to see a reason not to use it.
> can you tell me where exactly "pystone" does string concatenations?

No, not without more in depth examination, but it is a pretty common  
operation in all sorts of cases including inside the interpreter.   
Larry's message in reply to Gregory Smith's request for a pystone  
score showed a 5.5% improvement and as yet I have no reason to doubt  
it.  If the patch provides a measurable performance improvement for  
code that merely happens to use strings as opposed to being  
explicitly heavy on string addition then all the better.

It's clear that this needs to be more carefully measured before it  
goes in (which is why that quote above starts "If").  As I've  
mentioned before in this thread, getting good performance measures on  
code that does lazy evaluation is often tricky.  pystone is a good  
place to start but I'm sure that there are use cases that it does not  

As for counting up the downsides, Josiah Carlson rightly points out  
that it breaks binary compatibility for modules, so the change can  
not be taken lightly and clearly it will have to wait for a major  
release.  Still, if the benefits outweigh the costs it seems worth  


More information about the Python-Dev mailing list