3 ms·
My understanding of python is that all operators are shorthands for calling methods on the objects. E.g. 1 + 2 translates to 1.__add__(2) and
by wodenokoto 5y ago
My understanding of python is that all operators are shorthands for calling methods on the objects.
E.g.
1 + 2
translates to
1.__add__(2)
and
a += b
translates to
a.__iadd__(b)
So the difference between `+` and `+=` are dependent on the object in question.
Then in practise, there are a lot of optimizations and implementation details.