[issue17973] FAQ entry for: '+=' on a list inside tuple both succeeds and raises an exception

Ronald Oussoren report at bugs.python.org
Mon May 20 13:39:46 CEST 2013


Ronald Oussoren added the comment:

issue-17973-experimental.txt is a very crude first attempt at catching augment assignment to an immutable LHS. On first glance the code works, but it causes problems in the test suite and hence isn't correct yet. The generated code also isn't optimal, the LHS is evaluated too many times.

With the patch ``([],)[0] += ['a']`` raises an exception, and doesn't update the list. 

I also haven't done benchmarking of the code, I'd expect a slowdown in micro benchmarks for augmented assignment when the LHS isn't a simple name because there is more byte code (``a[0] += b`` disassembly expands from 8 to 14 lines).

----------
Added file: http://bugs.python.org/file30318/issue-17973-experimental.txt

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17973>
_______________________________________


More information about the Python-bugs-list mailing list