3 ms·
IINM the reference implementation has a cache for small integers. I wonder what happens if you try the ctypes example in the article with one of the cached inte
by scardine 7y ago
IINM the reference implementation has a cache for small integers. I wonder what happens if you try the ctypes example in the article with one of the cached integers.
- scardine 7y agoNothing happens with the cache. According to the article you can't use a Python int, instead you have to use a ctypes.c_int and those are not cached.
- knome 7y agoThis is an excellent question with a generally fun answer, at least in python 2. https://kate.io/blog/2017/08/22/weird-python-integers/ https://kate.io/blog/2017/08/22/weird-python-integers/ http://hforsten.com/redefining-the-number-2-in-python.html http://hforsten.com/redefining-the-number-2-in-python.html I found these offhand, but I'm pretty sure I saw this trick earlier than 2017.