Merging LOAD_METHOD and LOAD_ATTR for better specialization
#400
Replies: 4 comments 12 replies
|
If I understand correctly, what you are suggesting is similar to what we do with When you say "the unbound method optimisation" do you mean avoiding the creation of bound methods, or something else? If you want to try this, then I'd suggest keeping |
|
I like this idea. To summarize my thoughts:
The semantics of |
|
It might be worth taking a look at #396 before doing this. |
|
I opened python/cpython#93430 for this.
Agreed. We can reduce the cache size after merging too. Unless the bigger cache actually causes an immediate perf regression. |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Currently, a good portion of
LOAD_METHODfailures are that the method is an instance attribute.I've always wondered if we could overwrite
LOAD_METHODwithLOAD_ATTR, then letLOAD_ATTRspecialize for attribute accesses. The only change we'd need to do is thatLOAD_ATTRnow needs to pushNULLonto the stack, but we're on that path anyways (withLOAD_GLOBALpushingNULLfor calls as well. We also need to ensure that inline_cache_entries(LOAD_METHOD) >= inline_cache_entries(LOAD_ATTR)My main concern is that this will break certain assumptions by code introspection tools. However, I don't know what's the extent.
Another obvious downside is that we may lose the unbound method optimisation. That's roughly a 20% speedup lost.
LOAD_ATTRspecialization itself is a 20% gain though so it might balance out. Also I don't expect many unbound methods in such scenarios.All reactions