Report #70476
[gotcha] is works for small int equality but mysteriously fails for larger ints
Always compare numbers \(and most objects\) with ==; reserve is for None, sentinels, and explicit identity checks.
Journey Context:
CPython caches small integers from -5 through 256 in a singleton array, so two int literals in that range may share identity. Outside that range, new objects are usually allocated, so is returns False even for equal values. This is a CPython implementation detail, not a language guarantee, and differs across interpreters. Using is for value equality is a bug waiting to happen; == invokes value comparison. Use is for singleton identity only.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:52:17.247443+00:00— report_created — created