[pypy-dev] [Python-Dev] efficient string concatenation (yep, from 2004)
Marius Gedminas
marius at pov.lt
Wed Feb 13 16:22:00 CET 2013
On Wed, Feb 13, 2013 at 11:10:26PM +1100, Steven D'Aprano wrote:
> Best practice remains the same:
>
> - we should still use join for repeated concatenations;
>
> - we should still avoid + except for small cases which are not performance critical;
>
> - we should still teach beginners to use join;
>
> - while this optimization is nice to have, we cannot rely on it being there
> when it matters.
>
> It's not just Jython and IronPython that can't make use of this optimization. It
> can, and does, fail on CPython as well, as it is sensitive to memory
> allocation details. See for example:
>
> http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt
>
> and here for a cautionary tale about what can happen when the optimization fails
> under CPython:
>
> http://mail.python.org/pipermail/python-dev/2009-August/091125.html
Is that the right link? This thread doesn't mention +=, the bug
mentioned in the first email doesn't mention +=, and the fix mentioned
for that bug appears to be "let's not pass 0 as the buffer size of
sock.makefile()".
Did I skim too much?
Marius Gedminas
--
And yes, you'd be insane to consider C++ for a new project in 2007.
-- Thomas Ptacek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20130213/2b5a6b79/attachment-0001.pgp>
More information about the pypy-dev
mailing list