0

What is the function of inplace operators really coz x=4 x=x+4 x 8 (this serves the same function)

Anyone there, thanks

14th Jul 2016, 11:17 AM
hacker charlo
hacker charlo - avatar
2 odpowiedzi
+ 2
from the view of the programmer, they are basically the same except inplace operators may increase readabillity in some cases. from the view of interpreter, they may be implemented differently so inplace operators can be more efficient (not completely sure if python does this, but there are separate magic functions for regular and inplace operations) because x = x + 1 are two operations (addition and assignment) while x+=1 is one operation.
14th Jul 2016, 1:11 PM
RedAnt
RedAnt - avatar
+ 2
My personal opinion is, they created such syntax for better understanding and easy usage. x+=1 x=x+1 both may looks easy but My_lengthy_variable_name = My_lengthy_variable_name + 1 takes time than My_lengthy_variable_name +=1
17th Jul 2016, 6:02 PM
sundar
sundar - avatar