[Python-Dev] RFD: how to build strings from lots of slices?

Guido van Rossum guido@python.org
Sun, 27 Feb 2000 10:40:09 -0500


> The general approach is "cords" (in Hans Boehm's GC, garbage-collected),
> and "ropes" (in SGI's STL, http://www.sgi.com/Technology/STL/Rope.html,
> reference-counted).
> 
> It's a great idea, IMO.  Why create and copy strings all the time?

Each of these "improvements" slows things down in the common case.

Believe me, I thought about this a lot when I designed Python's string
object.  ABC had an extremely complicated string implementation that
used tricks like this and was proven to be asymptotically optimal.
Unfortunately, the constant factor was large, and it was very slow for
typical string ops.

KISS, folks!

--Guido van Rossum (home page: http://www.python.org/~guido/)