Conversation
Comparison using 'is' when equivalence is not the same as identity
|
Can one of the admins verify this patch? |
|
That is a good change, but an interesting tidbit: in CPython this actually works properly because the interpreter will cache numeric constants and short string constants at compile time. So assigning a variable to the value of a small string actually just points it at the existing object. Since strings and numbers are immutable, this is totally safe. But it's wrong to rely on implementation quirks. |
ocket8888
left a comment
There was a problem hiding this comment.
Please fill out the Pull Request template to the best of your ability.
|
as nornagon says in electron/electron#17864 (comment) "Python deduplicates small integers (<= 256) so is works on them, but larger integers get their own instance and don't compare equal with is any more." |
|
I didn't realize there was a size limit on integers. Wonder how it handles negative integers? |
|
I also agree with this change, and IMO this change is so simple and obvious that I'd let it bypass filling out the PR template. Next time, please fill it out though, it helps reviewers a lot. |
|
I disagree. One of the big things pushed for in the new template was "what versions of TC are affected by this bug?". This bug almost certainly exists in 3.0.x, and it'd be nice to have a record of that. Most sections can easily be filled in with N/A or a short description for such a small change. Deleting the PR template is a bad habit that I'm loathe to encourage. |
|
I Will edit adding PR template 🐶 |
|
Obsolete as of #3691 |
Comparison using 'is' when equivalence is not the same as identity