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

Larry Hastings larry at hastings.org
Fri Oct 13 10:10:52 CEST 2006

I've uploaded a new patch to Sourceforge in response to feedback:
  * I purged all // comments and fixed all > 80 characters added by my 
patch, as per Neil Norwitz.
  * I added a definition of max() for those who don't already have one, 
as per skip at pobox.com.
It now compiles cleanly on Linux again without modification; sorry for 
not checking that since the original patch.

I've also uploaded my hacked-together benchmark script, for all that's 

That patch tracker page again:

M.-A. Lemburg wrote:
> When comparing results, please look at the minimum runtime.
> The average times are just given to indicate how much the mintime
> differs from the average of all runs.
I'll do that next time.  In the meantime, I've also uploaded a zip file 
containing the results of my benchmarking, including the stdout from the 
run and the "-f" file which contains the pickled output.  So you can 
examine my results yourself, including doing analysis on the pickled 
data if you like.

> If however the speedups are not consistent across several runs of
> pybench, then it's likely that you have some background activity
> going on on the machine which causes a slowdown in the unmodified
> run you chose as basis for the comparison.
The machine is dual-core, and was quiescent at the time.  XP's scheduler 
is hopefully good enough to just leave the process running on one core.

I ran the benchmarks just once on my Linux 2.6 machine; it's a dual-CPU 
P3 933EB (or maybe just 866EB, I forget).  It's faster overall there 
too, by 1.9% (minimum run-time).  The two tests I expected to be faster 
("ConcatStrings" and "CreateStringsWithConcat") were consistently much 
faster; beyond that the results don't particularly resemble the results 
from my XP machine.  (I uploaded those .txt and .pickle files too.)

The mystery overall speedup continues, not that I find it unwelcome.  :)

> Just to make sure: you are using pybench 2.0, right ?
I sure was.  And I used stringbench.py downloaded from here:



More information about the Python-Dev mailing list