[New-bugs-announce] [issue44525] Implement CALL_FUNCTION adaptive interpreter optimizations

Ken Jin report at bugs.python.org
Mon Jun 28 10:22:18 EDT 2021


New submission from Ken Jin <kenjin4096 at gmail.com>:

CALL_FUNCTION can be specialized. Copying from Mark's comments https://github.com/faster-cpython/ideas/issues/54#issue-898013125

```
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 https://github.com/faster-cpython/ideas/issues/54#issuecomment-868978681 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.

----------
messages: 396639
nosy: Mark.Shannon, kj
priority: normal
severity: normal
status: open
title: Implement CALL_FUNCTION adaptive interpreter optimizations
type: performance
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44525>
_______________________________________


More information about the New-bugs-announce mailing list