[Python-Dev] Usage of += on strings in loops in stdlib
Larry Hastings
larry at hastings.org
Wed Feb 13 09:52:18 CET 2013
More information about the Python-Dev mailing list
Wed Feb 13 09:52:18 CET 2013
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 02/12/2013 05:25 PM, Christian Tismer wrote:
> Ropes have been implemented by Carl-Friedrich Bolz in 2007 as I remember.
> No idea what the impact was, if any at all.
> Would ropes be an answer (and a simple way to cope with string mutation
> patterns) as an alternative implementation, and therefore still justify
> the usage of that pattern?
I've always hated the "".join(array) idiom for "fast" string
concatenation--it's ugly and it flies in the face of TOOWTDI. I think
everyone should use "x = a + b + c + d" for string concatenation, and we
should just make that fast.
In 2006 I proposed "lazy string concatenation", a sort of rope that hid
the details inside the string object. If a and b are strings, a+b
returned a string object that internally lazily contained references to
a and b, and only computed its value if you asked for it. Here's the
Unicode version:
http://bugs.python.org/issue1629305
Why didn't it get accepted? I lumped in lazy slicing, a bad move as it
was more controversial. That and the possibility that macros like
PyUnicode_AS_UNICODE could now possibly fail, which would have meant
checking 400+ call sites to ensure they handle the possibility of
failure. This latter work has already happened with the new efficient
Unicode representation patch.
I keep thinking it's time to revive the lazy string concatenation patch.
//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/064734f7/attachment.html>
- Previous message: [Python-Dev] Usage of += on strings in loops in stdlib
- Next message: [Python-Dev] Usage of += on strings in loops in stdlib
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list