3 ms·
Second case is because of the range of integers that are cached, right?
by odonnellryan 11y ago
Second case is because of the range of integers that are cached, right?
- Veedrac 11y agoIt's actually more complicated than that. CPython will cache constants within a scope, so a = 500 b = 500 a is b will give `True`. But the REPL forces each line to compile separately and CPython won't cache across them. However, there's a global cache for integers less than 256 so in that case they're `is`-equivalent even in the REPL.