You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In-place operators lead to more concise code that is still readable. I'm not sure if there's any objective drawbacks (like a common pitfalls for certain types). And performance-wise my understanding is that it should be faster (due to the in-place nature) or equivalent (thanks to Python duck-typing that will fallback to __add__ if __iadd__ is not implemented).
Example
# Badsome_string= (
some_string+"a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long end of string"
)
index=index-1a_list=a_list+ ["to concat"]
some_set=some_set| {"to concat"}
to_multiply=to_multiply*5to_divide=to_divide/5to_cube=to_cube**3timeDiffSeconds=timeDiffSeconds%60flags=flags&0x1# etc.# Goodsome_string+="a veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery long end of string"index-=1a_list+= ["to concat"]
some_set|= {"to concat"}
to_multiply*=5to_divide/=5to_cube**=3timeDiffSeconds%=60flags&=0x1# etc.
The text was updated successfully, but these errors were encountered:
Explanation
In-place operators lead to more concise code that is still readable. I'm not sure if there's any objective drawbacks (like a common pitfalls for certain types). And performance-wise my understanding is that it should be faster (due to the in-place nature) or equivalent (thanks to Python duck-typing that will fallback to
__add__
if__iadd__
is not implemented).Example
The text was updated successfully, but these errors were encountered: