Would the builtins import look like this:

if not hasattr(__builtins__, 'first'):
    from more_itertools.more import first

Or this:

import sys
if sys.version_info[:2] < (3,9):
    from more_itertools.more import first

Having the same argspec as more_itertools.more.first would get us a free
backport.

On Fri, Dec 13, 2019, 6:05 PM Oscar Benjamin <oscar.j.benja...@gmail.com>
wrote:

> On Fri, 13 Dec 2019 at 22:47, Tim Peters <tim.pet...@gmail.com> wrote:
> >
> > [Christopher Barker]
> > >> I think we all agree that it does not belong in __builtins__,
> >
> > [Greg Ewing]
> > > Do we?
> >
> > Nobody yet has argued in favor of it - or even suggested it.
> >
> > > I'm not convinced.
> >
> > And that remains true even now ;-)  The new part here is that yours is
> > the first message to mention it that did _not_ say outright that
> > first() does not belong in the builtins.
> >
> > > We already have all() and any() in builtins, which are similar
> > > in that they operate on iterators or iterables.
> >
> > Also things like map() and zip(), but things like that predate
> > itertools.  My view is that first() just isn't likely to be used often
> > enough to merit making it a builtin.  all() and any() are.  If we had
> > it to do over, I bet zip() would have been assigned to itertools.
> > map() is too close to call, although these days, in new code, I
> > usually see a list comprehension where I used to see map().
>
> I think that first could get wider usage than next. Outside of
> implementing abstract iterator tools my experience is that the bulk of
> situations in which next is used/suggested would be better handled by
> (the raising version of) first.
>
> --
> Oscar
> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/python-ideas@python.org/message/YSCTQUPQAJOXRJLYB7HMMTNJXGQZQYYO/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EX75REDTRJAAVXMOCCECFYUTFZNUR3QZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to