Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: > > Josiah Carlson wrote: > > > 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. > > Nor {} as I proposed

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > On 8/27/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > [1] When I say "tree persistance", I mean those cases like a -> b -> c, > > where view b persist because view a persists, even though b doesn't have > > a reference otherwise. Making both

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Greg Ewing
Josiah Carlson wrote: > 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 Given Guido's sensitivity about potential misuses of views, it might be better i

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Delaney, Timothy (Tim)
Josiah Carlson wrote: > 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. Nor {} as I proposed for that matter ;) Tim Delaney _

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Greg Ewing
Jim Jewett wrote: > On 8/27/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Any object? And how is that supposed to work for arbitrary > > objects? > > For non-iterables, it will raise a TypeError. I think the question was what benefit would there be in a general slice-view object which knew

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote: > > Jim Jewett wrote: > > > On 8/27/06, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> wrote: > >> Jim Jewett wrote: > > > >>> s[start:stop].find(prefix) > > > >> No matter what, I really think the obj[start:stop:step] > >> syntax needs to be

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Guido van Rossum
On 8/27/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > On 8/27/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > On 8/26/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > > > > For example, you wanted to keep the rarely used optional arguments to > > > find because of efficiency. > > > I don't believe the

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Delaney, Timothy (Tim)
Jim Jewett wrote: > On 8/27/06, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> 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 - > >

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Jim Jewett
On 8/27/06, Delaney, Timothy (Tim) <[EMAIL PROTECTED]> 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 lo

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Delaney, Timothy (Tim)
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 - and that that behaviour be to return a copy. I'm not at all in favour of sometimes getting a copy, and so

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Jim Jewett
On 8/27/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > On 8/26/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > > For example, you wanted to keep the rarely used optional arguments to > > find because of efficiency. > I don't believe they are rarely used. They are (currently) essential > for code t

Re: [Python-3000] find -> index patch

2006-08-27 Thread Guido van Rossum
On 8/27/06, Jack Diederich <[EMAIL PROTECTED]> wrote: > What is with the sudden rush to solve all problems by using slice objects?> > I've never used a slice object and I don't care to start now. The above code > reads just fine as > > i = s.find('\n', start, stop) > if i >= 0: > yield s[:i] H

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Guido van Rossum
On 8/27/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > [1] When I say "tree persistance", I mean those cases like a -> b -> c, > where view b persist because view a persists, even though b doesn't have > a reference otherwise. Making both views a and b reference c directly > allows for b to be fr

Re: [Python-3000] find -> index patch

2006-08-27 Thread Jack Diederich
On Mon, Aug 28, 2006 at 01:37:59AM +1000, Nick Coghlan wrote: > Jack Diederich wrote: > > On Sat, Aug 26, 2006 at 07:51:03PM -0700, Guido van Rossum wrote: > >> On 8/26/06, Jack Diederich <[EMAIL PROTECTED]> wrote: > >>> After some benchmarking find() can't go away without really hurting > >>> rea

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
"Guido van Rossum" <[EMAIL PROTECTED]> wrote: > > 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 generalizat

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Guido van Rossum
On 8/27/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > Can you explain in a sentence or two how these changes would be > > *used*? Your code examples don't speak for themselves (maybe because > > It's Saturday morning :-). Short examples of something clumsy and/or > > slo

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Guido van Rossum
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: > >

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Guido van Rossum
On 8/26/06, Jim Jewett <[EMAIL PROTECTED]> wrote: > > > As I understand it, Nick is suggesting that slice > > > objects be used as a sequence (not just string) > > > view. > > > I have a hard time parsing this sentence. A slice is > > an object with three immutable attributes -- start, > > stop, st

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
Nick Coghlan <[EMAIL PROTECTED]> wrote: [snip] > that isn't likely to trigger an obvious error. It also breaks the persistent > idiom that "seq[:]" makes a copy (which is true throughout the standard > library, even if it isn't true for external number-crunching libraries like > NumPy). The co

Re: [Python-3000] find -> index patch

2006-08-27 Thread Nick Coghlan
Jack Diederich wrote: > On Sat, Aug 26, 2006 at 07:51:03PM -0700, Guido van Rossum wrote: >> On 8/26/06, Jack Diederich <[EMAIL PROTECTED]> wrote: >>> After some benchmarking find() can't go away without really hurting >>> readline() >>> performance. >> Can you elaborate? readline() is typically i

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Nick Coghlan
Guido van Rossum wrote: > Can you explain in a sentence or two how these changes would be > *used*? Your code examples don't speak for themselves (maybe because > It's Saturday morning :-). Short examples of something clumsy and/or > slow that we'd have to write today compared to something fast and

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Nick Coghlan
Jim Jewett wrote: > On 8/26/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: >> On 8/26/06, Jim Jewett <[EMAIL PROTECTED]> wrote: >> > As I understand it, Nick is suggesting that slice >> > objects be used as a sequence (not just string) >> > view. > >> I have a hard time parsing this sentence. A s

Re: [Python-3000] Making more effective use of slice objects in Py3k

2006-08-27 Thread Josiah Carlson
"Jim Jewett" <[EMAIL PROTECTED]> wrote: > > On 8/26/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > > Nick Coghlan <[EMAIL PROTECTED]> wrote: > > > > There are a couple of existing workarounds for > > > this: buffer() objects, and the start/stop arguments > > > to a variety of string methods. Ne