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

Stefan Behnel stefan_ml at behnel.de
Fri Jul 19 19:06:15 CEST 2013


Joshua Landau, 19.07.2013 11:05:
> One conclusion I think it's safe to take from this is that it is *not*
> a clear-cut issue as many people, myself included, had assumed. I
> think it's fair to say that people claiming (Stefan Behnel in this
> case, because it was the first quotation I found):
> 
>> IMHO, the reason why sum() supports other input types than numbers is that
>> in Python 2, at the time when it was implemented, there was no clear
>> definition of a "number"
> 
> or similar have missed this point.

Not sure what point you mean exactly here, but as I said before, using
sum() on lists of lists seems like one of those cool little hacks at first,
but actually isn't. It's really just a bad idea. Even if you personally
don't consider it weird that lists can be summed up, it definitely violates
the "don't make me think" principle for many people.

Rephrasing the quote above, I actually consider sum(lists) an
implementation artefact. Definitely not a feature, and most likely not even
deliberate.

Stefan




More information about the Python-ideas mailing list