My code is:
x = 1000
y = x + 0
z = 1000
print(x is y, x is z, y is z)
In REPL mode I have next result:
>>> False False False
But if I run script in script mode (like '1.py' for example) I have next result.
>>> False True False
Similar result in REPL with
>>> x = 1000; y = x + 0; z = 1000
>>> print(x is y, x is z, y is z)
False True False
I think that lexical analyzer make object optimization by translate my code to bite code. But I can't find desciption this process in documentation or books.
Where can I learn this material?
UPD: I need description in official notes. Like python.org. How to work AST-analizer optimization for example.
UPD2: It is desirable without the need to study the CPython source code in depth.