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

Larry Hastings larry at hastings.org
Mon Oct 9 07:47:58 CEST 2006


Fredrik Lundh wrote:
> skip at pobox.com wrote:
>   
>> MAL's pybench would probably be better for this presuming it does some
>> addition with string operands.
>>     
> or stringbench.
>   

I ran 'em, and they are strangely consistent with pystone.

With concat, stringbench is ever-so-slightly faster overall.  "172.82" 
vs "174.85" for the "ascii" column, I guess that's in seconds.  I'm just 
happy it's not slower.  (I only ran stringbench once; it seems to take 
*forever*).

I ran pybench three times for each build.  The slowest concat overall 
time was still 2.9% faster than the fastest release time.  
"ConcatStrings" is a big winner, at around 150% faster; since the test 
doesn't *do* anything with the concatenated values, it never renders the 
concatenation objects, so it does a lot less work.  
"CreateStringsWithConcat" is generally 18-19% faster, as expected.  
After that, the timings are all over the place, but some tests were 
consistently faster: "CompareInternedStrings" was 8-12% faster, 
"DictWithFloatKeys" was 9-11% faster, "SmallLists" was 8-15% faster, 
"CompareLongs" was 6-10% faster, and "PyMethodCalls" was 4-6% faster.  
(These are all comparing the "average run-time" results, though the 
"minimum run-time" results were similar.)

I still couldn't tell you why my results are faster.  I swear on my 
mother's eyes I didn't touch anything major involved in 
"DictWithFloatKeys", "SmallLists", or "CompareLongs".  I didn't touch 
the compiler settings, so that shouldn't be it.  I acknowledge not only 
that it could all be a mistake, and that I don't know enough about it to 
speculate.//

The speedup mystery continues,


*larry*


More information about the Python-Dev mailing list