Python console - different variables appeared to be the same object when code copied to console as block

Hello,

This what I noticed, using Pycharm's Python console

When the code below is copied to console as block, variables 'a' and 'b' are the same objects

>>>
a = 1000 b = 1000 print (a is b) True
>>> id(a) 36079236 >>> id(b) 36079236

But in this case, when entering code line by line, both variables are different objects

>>>
a = 1000 >>> b = 1000 >>> print (a is b) False

Could it be that in the first case PyCharm doing some kind of optimization like

>>>
a = b = 1000 >>> print (a is b) True


Thanks for help
 

 

Please sign in to leave a comment.