Report #51782
[gotcha] Identity check is works for small integers but fails for larger values
Always use == for value equality; reserve is for None and explicit sentinel checks only
Journey Context:
CPython caches small integers \(-5 to 256\) for performance, so is appears to work for value comparison within this range. For larger numbers, identity differs despite equal values. is checks object identity \(memory address\), not equivalence. Relying on small-int caching is implementation-dependent \(PyPy behaves differently\) and breaks silently when values exceed the cache threshold.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:24:26.880712+00:00— report_created — created