3 ms·
Here's one from https://stackoverflow.com/questions/15171695/whats-with-the-integer-cache-inside-python https://stackoverflow.com/questions/15171695/whats-with-
by rajathagasthya 9y ago
Here's one from https://stackoverflow.com/questions/15171695/whats-with-the-integer-cache-inside-python https://stackoverflow.com/questions/15171695/whats-with-the-...:
In [1]: a = 1
In [2]: b = 1
In [3]: a is b
Out[3]: True
In [4]: a = 257
In [5]: b = 257
In [6]: a is b
Out[6]: False
- raverbashing 9y agoYes, because the smaller ints are 'pre-constructed' in Python (hence all 1's are the same "int(1)" object)