Message192956
> This "optimisation" is a semantic change. It breaks backward
> compatibility in cases where a = a + b and a += b do not result
> in the name a having the same value. In particular this breaks
> backward compatibility for numpy users.
I didn't knew that. Then I guess original fastsum.patch can't be used. Since this is not the first time when someone suggests to use __add__+__iadd__ in sum, I suggest to extend existing warning with your example so that future developers would not be tempted to follow the same approach.
Patch fastsum-iadd_warning.patch attached and can be applied to 2.7.5, 3.3.2 and hg-tip.
Apart from this patch there're still 3 options remaining (special case in sum() for some types; general interface for sequence-like types; individual optimisation for individual types), that are to be discussed yet. Example patch of special case for lists and tuples attached. |
|
Date |
User |
Action |
Args |
2013-07-12 18:47:28 | Sergey | set | recipients:
+ Sergey, aleax, terry.reedy, jcea, ethan.furman, Ramchandra Apte, serhiy.storchaka, oscarbenjamin |
2013-07-12 18:47:28 | Sergey | set | messageid: <1373654848.12.0.916477300337.issue18305@psf.upfronthosting.co.za> |
2013-07-12 18:47:28 | Sergey | link | issue18305 messages |
2013-07-12 18:47:27 | Sergey | create | |
|