3 ms·
> 1000 + 1 is not 100 'is' actually checks memory locations and not equity. Because of the way Python caches small integers, anything from 0 through X will ma
by true_religion 13y ago
> 1000 + 1 is not 100
'is' actually checks memory locations and not equity.
Because of the way Python caches small integers, anything from 0 through X will map to the same memory location. But a large integer (say 1001) will map to a new memory location each time its created.
- wahnfrieden 13y agoTo get more specific, this object aliasing is an implementation detail. You can't expect different Python implementations to do it the same.