The Small-Int Cache Boundary
x = 1000
a = x - 744 # computed at runtime, not a literal
b = x - 744
print(a is b)
c = x - 743
d = x - 743
print(c is d)
a, b, c, and d are all built at runtime by subtracting from a variable, so CPython's compiler cannot fold them into a shared literal constant ahead of time. What does this print, under CPython 3.14?
Sign in to answer questions and track your progress
Sign In