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

David Mertz mertz at gnosis.cx
Tue Jul 16 05:22:23 CEST 2013


On Mon, Jul 15, 2013 at 7:12 PM, Ron Adam <ron3200 at gmail.com> wrote:

> >      + 1   Add specialised sum_iters(),  (based on the sum()
>
You mean chain.from_iterable?
>
> No, I mean a new function written in C, which writes (appends) the values
> directly into a new (or start) sequence.  Chain from_iterable builds a
> generator and yields the items out.  That's not going to be as fast, but it
> does use much less memory in many situations.


If a new function could *actually* be significantly faster than
chain.from_iterable(), I think it would be reasonable to have.  However, if
writing something new as basically an alias for 'list(chain(...))' only
gets us, say 10% speedup, I think nothing should be included.

But PLEASE, don't call such a new function sum_iters().  The obviously
correct name for such a thing is 'concat()'.  This is what I've argued a
bunch of times, but let's just call concatenation by its actual name rather
than try to squint in just the right way to convince ourselves that
"summation" is the same concept.



-- 
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/20130715/de441c20/attachment.html>


More information about the Python-ideas mailing list