Ka-Ping Yee wrote:
On Sun, 27 Feb 2000, Fredrik Lundh wrote:
here's one proposal, off the top of my head:
- introduce a PySliceListObject, which behaves like a
simple sequence of strings, but stores them as slices.
It occurred to me when i read this that *all* slices could be references within the original string, since strings are immutable. That is,
could return a PyStringRefObject that behaves just like a string, but contains a length y - x and a pointer to &(s->ob_sval) + x instead of the character data itself. The creation of this PyStringRefObject would increment the reference count of s by 1.
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?