bpo-26110: Add CALL_METHOD_KW
opcode to speedup method calls with keywords by Fidget-Spinner · Pull Request #26014 · python/cpython (original) (raw)
This is the keyword counterpart for CALL_METHOD
(which is only emitted for positional only method calls). The original CALL_METHOD
was inspired by PyPy. Not documented there is that PyPy also has a CALL_METHOD_KW
for the same purpose.
On microbenchmarks, there is a 1.2x speedup similar to the original patch by Yury for things like X.b(1, 2, c=3, d=4)
. On pyperformance, it isn't as noticeable -- mostly because pyperformance doesn't use keyword argument calls.
If accepted, docs and What's New (if necessary) will be a later patch.
A side effect of this is that CALL_METHOD
should also be slightly faster due to the elimination of a branch.