Message412005
`super().meth()` is expensive. I propose to optimize 3 parts of this:
1. Avoid creating a temporary super() proxy object.
2. Avoid creating a bound method.
3. Avoid method lookup in super MRO using the inline cache.
Credit for 1. and 2. doesn't belong to me. Those were inspired by the excellent work done in issue43563.
I'll do this by combining the adjacent CALL (super) and LOAD_METHOD instructions into CALL_NO_KW_SUPER__LOAD_METHOD. Using the specializer means:
- We don't touch any compiler code.
- This custom instruction isn't revealed to the user
- I can make use of the 5 cache entries shared by both CALL_ADAPTIVE and LOAD_METHOD_ADAPTIVE.
The final 2-argument super(type, obj).meth() form will have almost no overhead over a corresponding self.meth() call in the current implementation.
Please see https://github.com/faster-cpython/ideas/issues/242 and https://github.com/faster-cpython/ideas/discussions/239 for more info. |
|
Date |
User |
Action |
Args |
2022-01-28 16:36:58 | kj | set | recipients:
+ kj, Mark.Shannon |
2022-01-28 16:36:58 | kj | set | messageid: <1643387818.31.0.971991048266.issue46564@roundup.psfhosted.org> |
2022-01-28 16:36:58 | kj | link | issue46564 messages |
2022-01-28 16:36:58 | kj | create | |
|