3 ms·
It is syntactic sugar to call mylist.__iadd__. The behavior to modify it inplace is common also for other non-pure data structures. I'm not sure but I think th
by albertzeyer 11y ago
It is syntactic sugar to call mylist.__iadd__. The behavior to modify it inplace is common also for other non-pure data structures.
I'm not sure but I think that list.__iadd__ is even more tricky: When the new object still fits into the allocated array, it will modify it inplace, otherwise it returns a newly allocated list and doesn't modify it inplace. So you cannot rely on __iadd__ modifying a list (or anything else) inplace.
- Veedrac 11y ago> I'm not sure but I think that list.__iadd__ is even more tricky False; __iadd__ is always in-place for lists.