Eryk Sun added the comment:
The CPython interpreter doesn't centrally cache and reuse float objects, and
even if it did that would be an implementation detail, like what it does with
small int objects and strings.
What you're seeing at the module level is a compilation side effect. The
com
Rémi Lapeyre added the comment:
Hi rathinavelu thiruvenkatam, cPython has some optimizations where some
immutable constants will be folded in the same object to save memory so this is
not a bug, it's just that those optimization are not run when typing directly
in the shell.
You should just
New submission from rathinavelu thiruvenkatam :
af=1.1
bf=1.1
print(f'{af==bf},{af is bf}, {bf is af}' )
""" Script outputs
True,True, True.
On Shell
af=1.1
bf=1.1
print(f'{af==bf},{af is bf}, {bf is af}' )
True,False, False
"""
--
messages: 348790
nosy: rathinavelu thiruvenkatam