Advanced
Python
Q97 / 101
What is Python's "small integer" optimization?
Correct! Well done.
Incorrect.
The correct answer is B) CPython pre-allocates and caches integer objects for values -5 to 256; these are singletons in memory
B
Correct Answer
CPython pre-allocates and caches integer objects for values -5 to 256; these are singletons in memory
Explanation
a = 256; b = 256; a is b is True (same object). a = 257; b = 257; a is b may be False. This is a CPython implementation detail, not a language guarantee.
Progress
97/101