Report #99198
[gotcha] \`is\` appears to work for small integers and strings but fails for larger or dynamically created values
Compare values with \`==\` and identity with \`is\`; use \`is\` only for singletons such as \`None\`, \`True\`, \`False\`, and \`Ellipsis\`.
Journey Context:
CPython caches small integer objects for -5 through 256, so \`1000 is 1000\` may be True in a REPL but False when the same literal appears in different compilation units or after arithmetic. This makes \`is\` look like a value comparison by accident. Relying on it is an implementation detail that differs across Python implementations and even CPython builds; it also applies to string interning, which is not guaranteed. \`==\` invokes \`\_\_eq\_\_\` and compares value; \`is\` compares object identity. The confusion is reinforced by the fact that \`is\` works reliably for \`None\`, which is a true singleton. The right rule is simple but frequently violated: \`is\` for identity/singletons, \`==\` for equality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-29T04:44:04.964533+00:00— report_created — created