bpo-44337: Shrink the `LOAD_ATTR`/`STORE_ATTR` caches by brandtbucher · Pull Request #31517 · python/cpython
Can't the same idea shrink LOAD_METHOD from 3 entries down to 2? Then _PyAttrCache can be eliminated altogether.
I was looking at LOAD_METHOD yesterday, and it needs 3 slots of data for Python methods. It needs the type version, the shared dict-keys's version and a pointer to the Python function, in addition to the count and original oparg. We could try using 16 bits for one of the versions, saving a slot at the cost of more specialization failures.