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

Chetan Pandya pandyacus at gmail.com
Wed Oct 18 12:26:54 CEST 2006

The discussion on this topic seems to have died down. However, I had a look
at the patch and here are some comments:

This has the potential to speed up simple strings expressions like
s = '1' + '2' + '3' + '4' + '5' + '6' + '7' + '8'

However, if this is followed by
s += '9' this (the 9th string) will cause rendering of the existing value of
s and then create another concatenated string. This can, however, be
changed, but I have not checked to see if it is worth it.

The deallocation code needs to be robust for a complex tree - it is
currently not recursive, but needs to be, like the concatenation code.

Construct like s = a + b + c + d + e , where a, b etc. have been assigned
string values earlier will not benefit from the patch.

If the values are generated and concatenated in a single expression, that is
another type of construct that will benefit.

There are some other changes needed that I can write up if needed.


On 10/13/06, python-dev-request at python.org <python-dev-request at python.org>

> Date: Fri, 13 Oct 2006 12:02:06 -0700
> From: Josiah Carlson <jcarlson at uci.edu>
> Subject: Re: [Python-Dev] PATCH submitted: Speed up + for       string
>         concatenation, now as fast as "".join(x) idiom
> To: Larry Hastings <larry at hastings.org>, python-dev at python.org
> Message-ID: <20061013115748.09F2.JCARLSON at uci.edu>
> Content-Type: text/plain; charset="US-ASCII"
> Larry Hastings <larry at hastings.org> wrote:
> [snip]
> > 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.
> It's not.  Go into the task manager (accessable via Ctrl+Alt+Del by
> default) and change the process' affinity to the second core.  In my
> experience, running on the second core (in both 2k and XP) tends to
> produce slightly faster results.  Linux tends to keep processes on a
> single core for a few seconds at a time.
> - Josiah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20061018/0aa8795b/attachment.html 

More information about the Python-Dev mailing list