[issue17973] '+=' on a list inside tuple both succeeds and raises an exception
Ronald Oussoren
report at bugs.python.org
Fri May 17 17:07:14 CEST 2013
Ronald Oussoren added the comment:
You've got a point there. What about this patch (but then with proper english grammer)?
BTW. Actually fixing this wart would be possible, but at a significant cost: you'd have to change the implementation of LHS += RHS from:
tmp = LHS
tmp = tmp.__iadd__(RHS)
LHS = tmp
to:
tmp = LHS
LHS = tmp
tmp = tmp.__iadd__(RHS)
LHS = tmp
The odd assignment on the second line would detect that the LHS is immutable in 99+% of use cases before updating the RHS.
My gut feeling is that an implementation of this would have too high a cost (both in runtime performance and in a more complicated compiler), although it would be interesting to actually see a patch.
----------
keywords: +patch
Added file: http://bugs.python.org/file30294/faq-update.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17973>
_______________________________________
More information about the Python-bugs-list
mailing list