4 ms·
Would this affect other Python interpreters or just CPython?
by RandallBrown 3y ago
Would this affect other Python interpreters or just CPython?
- laurencerowe 3y agoThis seems to be a C extension so will likely only work with CPython, but since Python is so dynamic you can do all sorts of weird things just using plain Python.
- knome 3y agocpython 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.