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

Larry Hastings larry at hastings.org
Fri Sep 29 13:47:28 EDT 2006


Fredrik Lundh wrote:
> so what does the benchmark look like if you actually do this ?

Okay, timing this:
  x = ""
  for i in range(100000):
    x += "a"
  t = x[1] # forces the concat object to render

The result:
  Python 2.5 release: 30.0s
  Python 2.5 locally built: 30.2s
  Python 2.5 concat: 4.3s
  Improvement: 600% (1/7 of the time)


/larry/




More information about the Python-list mailing list