[Python-Dev] Usage of += on strings in loops in stdlib
Christian Tismer
tismer at stackless.com
Wed Feb 13 02:25:09 CET 2013
On 13.02.13 02:09, Alexandre Vassalotti wrote:
> On Tue, Feb 12, 2013 at 1:44 PM, Antoine Pitrou <solipsis at pitrou.net
> <mailto:solipsis at pitrou.net>> wrote:
>
> It's idiomatic because strings are immutable (by design, not
> because of
> an optimization detail) and therefore concatenation *has* to imply
> building a new string from scratch.
>
>
> Not necessarily. It is totally possible to implement strings such they
> are immutable and concatenation takes O(1): ropes are the canonical
> example of this.
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?
--
Christian Tismer :^) <mailto:tismer at stackless.com>
Software Consulting : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 : *Starship* http://starship.python.net/
14482 Potsdam : PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776 fax +49 (30) 700143-0023
PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04
whom do you want to sponsor today? http://www.stackless.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130213/cad9f55c/attachment-0001.html>
More information about the Python-Dev
mailing list