PATCH: Speed up direct string concatenation by 20+%!

Larry Hastings larry at hastings.org
Thu Oct 5 18:31:20 EDT 2006


Nicko wrote:
> I note that in both of those tests you didn't actually ever realise the
> concatenated string.  Can you give us figures for these tests having
> forced the concatenated string to be computed?

Sure, good call.  And bad news.

All these benchmarks were with functions taking N arguments that just
added (concatenated) the arguments and returned the result.  I only ran
each benchmark once.

             |  Python 2.5  |  Python 2.5
  arguments  |     release  |      concat
-------------+--------------+--------------
          2  |      7718ms  |      9078ms
          3  |      9203ms  |     10500ms
          4  |     10656ms  |     11656ms
          5  |     12156ms  |     13390ms
         20  |     29359ms  |     26703ms

Interpret as you see fit,


/larry/




More information about the Python-list mailing list