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

Andrew Barnert abarnert at yahoo.com
Fri Jul 12 06:03:24 CEST 2013


On Jul 11, 2013, at 18:34, Sergey <sergemp at mail.ru> wrote:

>> And again, what would be the benefit?
> 
> Hm. Benefits of O(N)-summable builtin types?
> * No more surprises "Oh, sum() is O(N**2) Why?"

No, it would be _more_ surprises. "Oh, sum() is O(N**2). Why? The docs say it's fast, it actually is fast for tuples, my class is just like a tuple."

This is exactly why people keep bringing up other types. I don't know what you're not getting here. If you want to argue that it's not a bad enough attractive nuisance to worry about, that might be a reasonable argument. But you've never made that argument; instead you just deny that the problem exists at all, going back and forth between claiming that we can make sum fast for all types and arguing that every type anyone brings up in an objection should be changed.


More information about the Python-ideas mailing list