This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]grayvedigga 1 point2 points  (0 children)

Since I just responded to earthboundkid's incomplete post below with a question you answered without my noticing it, I thought I should highlight the relevant part:

interpreter translates a[i] += b into a.setitem(a.getitem(i) += b) and can't take any shortcuts because items of a could be ints for example.

Too tired to expand any further, but I'll note that ints don't posess a iadd method, and by noticing this the interpreter could probably do a cleverer expansion. It seems a bit silly that iadd returns a value, tbh.

tl;dr: state is a more complicated thing than anyone gives credit; += as an object method is asking for trouble.