[Python-3000] Making more effective use of slice objects in Py3k
jcarlson at uci.edu
Mon Aug 28 04:20:42 CEST 2006
"Delaney, Timothy (Tim)" <tdelaney at avaya.com> wrote:
> Jim Jewett wrote:
> > On 8/27/06, Delaney, Timothy (Tim) <tdelaney at avaya.com> wrote:
> >> Jim Jewett wrote:
> >>> s[start:stop].find(prefix)
> >> No matter what, I really think the obj[start:stop:step]
> >> syntax needs to be consistent in its behaviour - either
> >> returning a copy or a view -
> > Does it still matter if we're looking only at immutable sequences,
> > such as text?
> Actually, yes. I think it should be an explicit operation to say "I'm
> taking a small view of this large string, which will result in the large
> string existing until the view goes away".
> Currently the way to do that is to have a method. I'm simply proposing
> that we reserve syntax that is currently not used to prevent it from
> being used for another, less appropriate usage. It may never be used at
In what I have been attempting to propose, no text methods would ever
return a view. If one wants a view of text, one needs to manually
construct the view via 'view = textview(st, start, stop)' or some
equivalent spelling. After that, any operations on a view returns views
(with a few exceptions, like steps != 1).
The seemingly proposed textobj(start:stop) returning a view is not
terribly intuitive, as () and  aren't so terribly different from each
other to not confuse someone initially. Never mind that it would be a
syntax addition for the equivalent of a small subset of operations on
currently existing objects.
More information about the Python-3000