4 ms·
The `is` operator is checking object identity by comparing addresses. It is useless, although it may sometimes produce reasonable-looking results due to optimis
by Kwpolska 3y ago
The `is` operator is checking object identity by comparing addresses. It is useless, although it may sometimes produce reasonable-looking results due to optimisations.
Python 3.11 gives me this:
>>> -0 is 0
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
Because (a) -0 is an integer, and there is only one integer zero, (b) small numbers have only one instance in memory as an optimization.