[Python-ideas] Fast sum() for non-numbers - why so much worries?
Steven D'Aprano
steve at pearwood.info
Wed Jul 10 19:20:38 CEST 2013
On 11/07/13 02:50, Ethan Furman wrote:
> Currently, sum() does not modify its arguments.
>
> You (or whoever) are suggesting that it should modify one of them.
>
> That makes it a semantic change, and a bad one.
>
> -1
Actually, Sergey's suggestion is a bit more clever than that. I haven't tested his C version, but the intention of his pure-Python demo code is to make a temporary list, modify the temporary list in place for speed, and then convert to whatever type is needed. That will avoid modifying any of the arguments[1]. So credit to Sergey for avoiding that trap.
[1] Except possibly in truly pathological cases which I for one don't care about.
--
Steven
More information about the Python-ideas
mailing list