The Python Oracle

"is" operator behaves unexpectedly with integers

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Over Ancient Waters Looping

--

Chapters
00:00 Question
01:04 Accepted answer (Score 448)
01:43 Answer 2 (Score 153)
07:24 Answer 3 (Score 75)
13:11 Answer 4 (Score 62)
13:48 Thank you

--

Full question
https://stackoverflow.com/questions/3063...

Accepted answer links:
["Plain Integer Objects"]: https://docs.python.org/3/c-api/long.htm...

Answer 2 links:
[documentation]: https://docs.python.org/2/reference/expr...
[documentation]: https://docs.python.org/library/function...
[PEP8 describes]: https://www.python.org/dev/peps/pep-0008...

Answer 3 links:
[PyLong_FromLong(long v)]: https://docs.python.org/3/c-api/long.htm...
[Objects]: https://hg.python.org/cpython/file/d4893.../
[main source code directory tree]: https://hg.python.org/cpython/file/tip
[longobject.c]: https://hg.python.org/cpython/file/tip/O...
[line 230]: https://hg.python.org/cpython/file/tip/O...
[Let's check it out:]: https://hg.python.org/cpython/file/tip/O...
[Here they are]: https://hg.python.org/cpython/file/tip/O...
[get_small_int]: https://hg.python.org/cpython/file/tip/O...
[We could've just read the damn documentation and we would've know all along!]: https://hg.python.org/cpython/file/tip/O...
[During initialization in ]: https://hg.python.org/cpython/file/tip/O...
[and I have attempted to do so already]: https://stackoverflow.com/questions/3414...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #int #operators #identity #pythoninternals

#avk47