sturlamolden wrote: > On Dec 12, 3:08 pm, Marc 'BlackJack' Rintsch <bj_...@gmx.net> wrote: > >> No bug because a mutation *is* attempted. ``a += x`` calls `a.__iadd__` >> which *always* returns the result which is *always* rebound to the name >> `a`. Even with mutable objects where `__iadd__()` simply returns >> `self`! > > No, a mutation is not attempted, even if __iadd__() always returns a > value. If a rebinding of a member to the same member is attempted, the > tuple should not raise an exception. The tuple should check that it is > actually being *mutated* before it raises any exception. There is an > attempted write to the tuple, but not an attempted mutation of the > tuple. The tuple should tell the difference. Immutability does not > imply inwriteability, if the write operation changes nothing. But the > tuple raises an exception on any write attempt. > OK, so if you regard the current behavior as a bug explain how to modify the tuple's __iadd__ method and the coding of the INPLACE_ADD operator. At least in pseudocode.
Criticism is easy. Now demonstrate that it's *informed* criticism. Enough of the "should". I am always suspicious of suggestions that say what the interpreter "should" or "should not" do. It makes it sound as though you can wave a magic wand to achieve the desired behavior. The interpreter "should not" have a GIL. The tuple "should" check that it is actually being mutated. How? regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list