Re: Documenting builtin methods

2013-07-12 Thread Joshua Landau
On 12 July 2013 04:43, alex23 wrote: > > My last post seems to have been eaten by either Thunderbird or the > EternalSeptember servers, but it contained an erroneous claim that the > straight function version performed as well as the factory one. However, in > the interim a co-worker has come up w

Re: Documenting builtin methods

2013-07-11 Thread alex23
On 12/07/2013 9:11 AM, Joshua Landau wrote: I also feel that: def factory(): eatit = deque(maxlen=0).extend def exhaust_iter(it): """Doc string goes here""" eatit(it) return exhaust_iter exhaust_it = factory() del factory is a very unobvious way to change a doc

Re: Documenting builtin methods

2013-07-11 Thread Joshua Landau
On 11 July 2013 07:06, Steven D'Aprano wrote: > > But really, I'm having trouble understanding what sort of application > would have "run an iterator to exhaustion without doing anything with the > values" as the performance bottleneck :-) Definitely not this one. Heck, there's even no real reaso

Re: Documenting builtin methods

2013-07-11 Thread Ben Finney
Joshua Landau writes: > On 11 July 2013 05:13, Joshua Landau wrote: > > > > Ah, I get it. It is easy to misread my post as "I have this > exhaust_iter" and it's obvious it doesn't work because why else would > I post here what do I do HALP! Right. Just because you think there's one obvious int

Re: Documenting builtin methods

2013-07-11 Thread Chris Angelico
On Thu, Jul 11, 2013 at 5:15 PM, Steven D'Aprano wrote: > On Thu, 11 Jul 2013 17:06:39 +1000, Chris Angelico wrote: > >> On Thu, Jul 11, 2013 at 4:06 PM, Steven D'Aprano >> wrote: >>> I think the right solution here is the trivial: >>> >>> def exhaust(it): >>> """Doc string here.""" >>> d

Re: Documenting builtin methods

2013-07-11 Thread Steven D'Aprano
On Thu, 11 Jul 2013 17:06:39 +1000, Chris Angelico wrote: > On Thu, Jul 11, 2013 at 4:06 PM, Steven D'Aprano > wrote: >> I think the right solution here is the trivial: >> >> def exhaust(it): >> """Doc string here.""" >> deque(maxlen=0).extend(it) >> >> >> which will be fast enough for al

Re: Documenting builtin methods

2013-07-11 Thread Chris Angelico
On Thu, Jul 11, 2013 at 4:06 PM, Steven D'Aprano wrote: > I think the right solution here is the trivial: > > def exhaust(it): > """Doc string here.""" > deque(maxlen=0).extend(it) > > > which will be fast enough for all but the tightest inner loops. But if > you really care about optimizi

Re: Documenting builtin methods

2013-07-10 Thread Steven D'Aprano
On Thu, 11 Jul 2013 04:15:37 +0100, Joshua Landau wrote: > I have this innocent and simple code: > > from collections import deque > exhaust_iter = deque(maxlen=0).extend At this point, exhaust_iter is another name for the bound instance method "extend" of one specific deque instance. Other i

Re: Documenting builtin methods

2013-07-10 Thread alex23
On 11/07/2013 1:15 PM, Joshua Landau wrote: I have this innocent and simple code: from collections import deque exhaust_iter = deque(maxlen=0).extend exhaust_iter.__doc__ = "Exhaust an iterator efficiently without caching any of its yielded values." Obviously it does not work. Is there a way to

Re: Documenting builtin methods

2013-07-10 Thread Joshua Landau
On 11 July 2013 05:13, Joshua Landau wrote: > Ah, I get it. It is easy to misread my post as "I have this exhaust_iter" and it's obvious it doesn't work because why else would I post here what do I do HALP! Yeah, sorry -- it wasn't meant to come across that way. -- http://mail.python.org/mailm

Re: Documenting builtin methods

2013-07-10 Thread Joshua Landau
On 11 July 2013 04:57, Ben Finney wrote: > Joshua Landau writes: > >> I have this innocent and simple code: >> >> from collections import deque >> exhaust_iter = deque(maxlen=0).extend >> exhaust_iter.__doc__ = "Exhaust an iterator efficiently without >> caching any of its yielded values." >> >>

Re: Documenting builtin methods

2013-07-10 Thread Ben Finney
Joshua Landau writes: > I have this innocent and simple code: > > from collections import deque > exhaust_iter = deque(maxlen=0).extend > exhaust_iter.__doc__ = "Exhaust an iterator efficiently without > caching any of its yielded values." > > Obviously it does not work. Right. It raises a Synta

Re: Documenting builtin methods

2013-07-10 Thread Mark Janssen
> I have this innocent and simple code: > > from collections import deque > exhaust_iter = deque(maxlen=0).extend > exhaust_iter.__doc__ = "Exhaust an iterator efficiently without > caching any of its yielded values." > > Obviously it does not work. Is there a way to get it to work simply > and wit