[Python-ideas] Fast sum() for non-numbers

David Mertz mertz at gnosis.cx
Thu Jul 11 19:02:03 CEST 2013


I'm not in love with it, but what about 'ichain()' following imap() and
izip(), ifilter(), etc.


On Thu, Jul 11, 2013 at 9:54 AM, Andrew Barnert <abarnert at yahoo.com> wrote:

> On Jul 11, 2013, at 7:31, Oscar Benjamin <oscar.j.benjamin at gmail.com>
> wrote:
>
> > On 11 July 2013 14:20, Ron Adam <ron3200 at gmail.com> wrote:
> >>
> >> On 07/11/2013 06:05 AM, Oscar Benjamin wrote:
> >>> On 11 July 2013 11:47, Ron Adam<ron3200 at gmail.com> wrote:
> >>
> >>   chain(iters)        # better in most cases...
> >
> > I think you mean chain.from_iterable rather than chain
> >
> >> I'd like to see chain as a builtin in any case.
> >
> > chain.from_iterable should be the builtin not chain.
>
> This is the problem. We can't rename chain.from_iterable to chain (or,
> equivalently, change the API of chain) while moving it without a lot of
> confusion. So it seems like we probably need to name it something
> completely different--concat, flatten, chainiter, ... But none of those
> names feels right. Concat seems like it should just take two sequences, not
> a sequence of sequences. Flatten is something you'd only reach for when
> you're thinking of it as one nested sequence rather than a collection of
> sequences. Chainiter is ugly. Chain really would be the perfect name if it
> didn't already have the wrong connotation thanks to its years of life in
> itertools.
>
> Other than that, I love the idea. The right function for this task should
> return an iterator, for the same reasons map and zip should, and also
> because it completely avoids all of the issues with trying to define what
> it means for different types by only handling iterables and treating them
> as iterables. The docs for sum already hint that it's the obvious way to
> concatenate sequences, but it should be more obvious.
>
> If someone can come up with a good name (or just nudge my feeling on one
> of the already proposed names), I'm definitely +1 on this.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130711/104524ec/attachment-0001.html>


More information about the Python-ideas mailing list