Sergey added the comment: > 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. ---------- Added file: http://bugs.python.org/file30904/fastsum-iadd_warning.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18305> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com