Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50421

Re: Documenting builtin methods

References <mailman.4558.1373512579.3114.python-list@python.org> <51de4b6c$0$11094$c3e8da3@news.astraweb.com>
Date 2013-07-11 17:06 +1000
Subject Re: Documenting builtin methods
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.4571.1373526402.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jul 11, 2013 at 4:06 PM, Steven D'Aprano <steve@pearwood.info> 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 optimizing this:
>
>
> 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
>
>
> which will be about as efficient as you can get while still having a
> custom docstring.

Surely no reason to go for the factory function:

def exhaust(it,eatit=deque(maxlen=0).extend):
	eatit(it)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-11 04:15 +0100
  Re: Documenting builtin methods alex23 <wuwei23@gmail.com> - 2013-07-11 15:35 +1000
  Re: Documenting builtin methods Steven D'Aprano <steve@pearwood.info> - 2013-07-11 06:06 +0000
    Re: Documenting builtin methods Chris Angelico <rosuav@gmail.com> - 2013-07-11 17:06 +1000
      Re: Documenting builtin methods Steven D'Aprano <steve@pearwood.info> - 2013-07-11 07:15 +0000
        Re: Documenting builtin methods Chris Angelico <rosuav@gmail.com> - 2013-07-11 17:23 +1000
    Re: Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-12 00:11 +0100
      Re: Documenting builtin methods alex23 <wuwei23@gmail.com> - 2013-07-12 13:43 +1000
        Re: Documenting builtin methods Joshua Landau <joshua@landau.ws> - 2013-07-12 08:09 +0100

csiph-web