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

Haoyi Li haoyi.sg at gmail.com
Tue Jul 9 02:39:50 CEST 2013


> Python programmers do currently write programs with linked lists.  And
they use what ever is in the library they think is useful... the whole
point of "batteries included".

On the other hand, python programmers do currently write programs with
normal lists, and sum(), and using sum() on lists would be useful. They're
BOTH in the standard library too! In fact, this seems like a perfect
argument for having sum() work on lists!

The objection seems like optimizing for a hypothetical, potential use case
far in the future at the expense of a concrete use case now. "if you can't
make it do EVERYTHING, then we shouldn't make it do ANYTHING or people will
get confused!" (paraphrased and exaggerated for theatrical effect).

This is all on the assumption that you consider flattening list-of-lists a
concrete use case. I for one find it annoying that i have to write a
verbose long thingy every time i need to flatten lists, and I have probably
needed to flatten lists about a dozen times in the last 3 months and used
linked lists not-at-all.

Maybe you write a ton of pure-functional algorithms making great use of the
persistence of singly-linked-lists for performant non-mutating
head-updates, and never use vanilla lists in the code you write, and so
having sum() work on linked lists is of great import.


On Tue, Jul 9, 2013 at 5:58 AM, Ron Adam <ron3200 at gmail.com> wrote:

>
>
> On 07/08/2013 03:22 PM, Sergey wrote:
>
>> >>(It's certainly unusual for python's “batteries included” philosophy).
>>>>
>>> >
>>> >What does "batteries included" have to do with excluding data types?
>>>
>> Excluding data types? What do you mean?
>>
>> I wasn't sure what you meant when you said about problems with linked
>> lists, so I was thinking that you mean something like "if one day
>> linked lists get their way into python standard libraries and people
>> will try using sum() on them..." That's why I said that such
>> implementation would be too skimped.
>>
>
> We need to keep in mind how python programmer will use the tools,
> "Batteries", we add to the library.
>
> Python programmers do currently write programs with linked lists.  And
> they use what ever is in the library they think is useful... the whole
> point of "batteries included".
>
> -Ron
>
>
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130709/7435ccff/attachment.html>


More information about the Python-ideas mailing list