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). Relates to #28
Proposal
Any of the following:
some_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.
Could be re-written as:
some_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:
Thank you for opening this! This sounds easy enough to implement, I'll give it a shot over the weekend.
Because anyone can make their own custom in-place operators, I think it is best to only support built-in types, though there should be an option to extend this to all types once I add option support (see #100).
Also, I'd probably add these to your list as well:
Overview
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). Relates to #28Proposal
Any of the following:
Could be re-written as:
The text was updated successfully, but these errors were encountered: