Author kj
Recipients Mark.Shannon, kj
Date 2021-06-28.14:22:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
CALL_FUNCTION can be specialized. Copying from Mark's comments

There are a number of specializations of CALL_FUNCTION that make sense:

1. Calls to a Python function where the arguments and parameters match exactly.
2. Calls to a Python function with keyword arguments, or defaults, when the argument shuffle can be pre-computed.
3. Calls to builtin functions.
4. Calls to specific builtin functions, specifically len and instance.
5. Calls to type with a single argument.
6. Instantiation of a "normal" class, that is a class that does not redefine __new__ and whose metaclass is type.

I've prepared a PR that should speed up non-keyword calls to PyCFunction. It covers specializations 3 and 4. Stable pyperf microbenchmarks show 5-15% less call overhead for some PyCFunctions. Please see for the benchmark script and results.

This issue is also tied to issue44207 (Add a version number to Python functions) which will be required for specializations 1 and 2.
Date User Action Args
2021-06-28 14:22:18kjsetrecipients: + kj, Mark.Shannon
2021-06-28 14:22:18kjsetmessageid: <>
2021-06-28 14:22:18kjlinkissue44525 messages
2021-06-28 14:22:17kjcreate