On 8/26/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > "Jim Jewett" <[EMAIL PROTECTED]> wrote: > > With stringviews, you wouldn't need to be reindexing from the start of > > the original string. The idiom would instead be a generalization of > > "for line in file:" > > > > while data: > > chunk, sep, data = data.partition() > > > > but the partition call would not need to copy the entire string; it > > could simply return three views. > > Also, with a little work, having string views be smart about > concatenation (if two views are adjacent to each other, like chunk,sep > or sep,data above, view1+view2 -> view3 on the original string), copies > could further be minimized, and the earlier problem with readline, etc., > can be avoided.
But this assumes that string views are 99.999% indiscernible from regular strings -- if operations can return a copy or a view depending on how things happen to be laid out in memory, It should be trivial to write code that doesn't care whether it gets a string or a view. This works for strings (which are immutable) but these semantics are unacceptable for mutable objects -- another reason to doubt that it makes sense to generalize the idea of views to all sequences, or to involve a change to the slice object in the design. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
