Re: [Python-Dev] _length_cue()

2006-02-11 Thread Bengt Richter
On Fri, 10 Feb 2006 14:33:08 +0100, Armin Rigo <[EMAIL PROTECTED]> wrote: >Hi Nick, > >On Fri, Feb 10, 2006 at 11:21:52PM +1000, Nick Coghlan wrote: >> Do they really need anything more sophisticated than: >> >>def __repr__(self): >> return "%s(%r)" % (type(self).__name__, self._subiter)

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Raymond Hettinger
[Armin] > It would be nicer if all these > iterators I'm not familiar with would give me a hint about what they > actually return, instead of: > itertools.count(17) > count(17) # yes, thank you, not very helpful I prefer that the repr() of count() be left alone. It follows t

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Nick Coghlan
Armin Rigo wrote: > Hi Nick, > > On Fri, Feb 10, 2006 at 11:21:52PM +1000, Nick Coghlan wrote: >> Do they really need anything more sophisticated than: >> >>def __repr__(self): >> return "%s(%r)" % (type(self).__name__, self._subiter) >> >> (modulo changes in the format of arguments, natu

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Armin Rigo
Hi Raymond, On Wed, Feb 08, 2006 at 09:21:02PM -0500, Raymond Hettinger wrote: > (... __getitem_cue__ ...) > Before putting this in production, it would probably be worthwhile to search > for code where it would have been helpful. In the case of __length_cue__, > there was an immediate payoff.

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Armin Rigo
Hi Nick, On Fri, Feb 10, 2006 at 11:21:52PM +1000, Nick Coghlan wrote: > Do they really need anything more sophisticated than: > >def __repr__(self): > return "%s(%r)" % (type(self).__name__, self._subiter) > > (modulo changes in the format of arguments, naturally. This simple one would

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Armin Rigo
Hi Greg, On Thu, Feb 09, 2006 at 04:27:54PM +1300, Greg Ewing wrote: > The iterator protocol is currently very simple and > well-focused on a single task -- producing things > one at a time, in sequence. Let's not clutter it up > with too much more cruft. Please refer to my original message: I in

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Nick Coghlan
Armin Rigo wrote: > Indeed, I don't foresee any place where it would help apart from the > __repr__ of the iterators, which is precisely what I'm aiming at. The > alternative here would be a kind of "smart" global function that knows > about many built-in iterator types and is able to fish for the

Re: [Python-Dev] _length_cue()

2006-02-10 Thread Raymond Hettinger
[Giovanni] >> I was really attracted to the idea of having more informative iterator >> representations but learned that even when it could be done, it wasn't >> especially useful. When someone creates an iterator at the >> interactive >> prompt, they almost always either wrap it in a consumer fun

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Bengt Richter
On Thu, 9 Feb 2006 09:54:59 -0600, [EMAIL PROTECTED] wrote: > >>> Ditto. In addition, we already have queues. Do we really need to >>> use a homonym that means something entirely different? (Hint: >>> consider the added difficulty for non-native English speakers). > >Guido> Righ

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Raymond Hettinger
> Hint seems like the standard terminology in the field. I don't think > it makes sense to invent our own terminology without some compelling > reason. Okay, I give, hint wins. Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.pyth

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Jack Diederich
[Raymond Hettinger] > [Armin Rigo] > > BTW the reason I'm looking at this is that I'm considering adding > > another undocumented internal-use-only method, maybe __getitem_cue__(), > > that would try to guess what the nth item to be returned will be. This > > would allow the repr of some iterators

Re: [Python-Dev] _length_cue()

2006-02-09 Thread skip
>> Ditto. In addition, we already have queues. Do we really need to >> use a homonym that means something entirely different? (Hint: >> consider the added difficulty for non-native English speakers). Guido> Right. As a non-native speaker I can confirm that for English Guido

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >>>> Might I suggest that at least you consider using "hint" instead of > "cue"? >... > >Greg> I agree that "hint" is a more precise name. > > Ditto. In addition, we already have queues. Do we really need to use a > homony

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Guido van Rossum
On 2/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Greg> I agree that "hint" is a more precise name. > > Ditto. In addition, we already have queues. Do we really need to use a > homonym that means something entirely different? (Hint: consider the added > difficulty for non-native Engl

Re: [Python-Dev] _length_cue()

2006-02-09 Thread Jeremy Hylton
Hint seems like the standard terminology in the field. I don't think it makes sense to invent our own terminology without some compelling reason. Jeremy On 2/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >> [Andrew Koenig] > >> > >>> Might I suggest that at least you consi

Re: [Python-Dev] _length_cue()

2006-02-09 Thread skip
>> [Andrew Koenig] >> >>> Might I suggest that at least you consider using "hint" instead of "cue"? ... Greg> I agree that "hint" is a more precise name. Ditto. In addition, we already have queues. Do we really need to use a homonym that means something entirely different

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Greg Ewing
Raymond Hettinger wrote: > [Andrew Koenig] > >>Might I suggest that at least you consider using "hint" instead of "cue"? > > Personally, I prefer "cue" which my dictionary defines as "a signal, hint, > or suggestion". The alternate definition of "a prompt for some action" > applies equally well

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Greg Ewing
Armin Rigo wrote: > This said, do we vote for __length_hint__ or __length_cue__? :-) I prefer something containing "hint" rather than "cue" because it more explicitly says what we mean. I feel that __length_hint__ is a bit long, though. We have __len__, not __length__, so maybe it should be __le

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Raymond Hettinger
[Armin Rigo] > Hi Raymond, . . . > This means that _length_cue() is at the moment a special method, in the > sense that Python can invoke it implicitely. Okay, that makes sense. Go ahead and make the swap. > This said, do we vote for __length_hint__ or __length_cue__? :-) I prefer __length_cu

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Armin Rigo
Hi Raymond, On Wed, Feb 08, 2006 at 03:02:21PM -0500, Raymond Hettinger wrote: > IMHO, the "safety reasons" are imaginary -- the scenario would involve > subclassing one of these builtin objects and attaching an identically named > private method. No, the senario applies to any user-defined ite

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Raymond Hettinger
[Armin Rigo] > It was replaced by an optional undocumented method called _length_cue(), > which would be used to guess the number of remaining items in an > iterator, for performance reasons. > > I'm worried about the name. There are now exactly two names that behave > like a special method withou

Re: [Python-Dev] _length_cue()

2006-02-08 Thread LD 'Gus' Landis
+1 on 'hint' vs 'cue'... also infers 'not definitive' (sort of like having a hint of how much longer the "honey do" list is... the honey do list is never 'exhaustive', only exhausting! ;-) On 2/8/06, Andrew Koenig <[EMAIL PROTECTED]> wrote: > > I'm worried about the name. There are now ex

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Guido van Rossum
+1 for __length_hint__. Raymond? On 2/8/06, Andrew Koenig <[EMAIL PROTECTED]> wrote: > > I'm worried about the name. There are now exactly two names that behave > > like a special method without having the double-underscores around it. > > The first name is 'next', which is kind of fine because i

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Andrew Koenig
> I'm worried about the name. There are now exactly two names that behave > like a special method without having the double-underscores around it. > The first name is 'next', which is kind of fine because it's for > iterator classes only and it's documented. But now, consider: the > CPython imple

Re: [Python-Dev] _length_cue()

2006-02-08 Thread Aahz
On Wed, Feb 08, 2006, Armin Rigo wrote: > > IMHO for safety reasons we need to stick double-underscores around this > name too, e.g. __length_cue__(). It's new in 2.5 and not documented > anyway so this change won't break anything. Do you agree with that? +1 -- Aahz ([EMAIL PROTECTED])

[Python-Dev] _length_cue()

2006-02-08 Thread Armin Rigo
Hi all, Last september, the __len__ method of iterators was removed -- see discussion at: http://mail.python.org/pipermail/python-dev/2005-September/056879.html It was replaced by an optional undocumented method called _length_cue(), which would be used to guess the number of remaining items in