3 ms·
cpython caches the small integers, and this is just grabbing a reference to 8 and 9 and then altering the value of the integer held in each cached reference. T
by knome 3y ago
cpython caches the small integers, and this is just grabbing a reference to 8 and 9 and then altering the value of the integer held in each cached reference.
The author could have skipped the c library and used the ctypes module to munge the bits.
There's no guarantee that any other version of python would use the same caching, same structure layout and certain not be able to link with the same c library.
So, yeah, it's specific.
A fun little adventure into how things work for the author, though.