This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Sergey
Recipients Ramchandra Apte, Sergey, aleax, ethan.furman, jcea, oscarbenjamin, serhiy.storchaka, terry.reedy
Date 2013-07-12.18:47:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373654848.12.0.916477300337.issue18305@psf.upfronthosting.co.za>
In-reply-to
Content
> 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.
History
Date User Action Args
2013-07-12 18:47:28Sergeysetrecipients: + Sergey, aleax, terry.reedy, jcea, ethan.furman, Ramchandra Apte, serhiy.storchaka, oscarbenjamin
2013-07-12 18:47:28Sergeysetmessageid: <1373654848.12.0.916477300337.issue18305@psf.upfronthosting.co.za>
2013-07-12 18:47:28Sergeylinkissue18305 messages
2013-07-12 18:47:27Sergeycreate