[New-bugs-announce] [issue27810] Add METH_FASTCALL: new calling convention for C functions

STINNER Victor report at bugs.python.org
Fri Aug 19 20:32:46 EDT 2016


New submission from STINNER Victor:

The issue #27128 added _PyObject_FastCall() to avoid the creation of temporary tuples when calling functions.

I propose to add a new METH_FASTCALL calling convention. The example using METH_VARARGS | METH_KEYWORDS:
   PyObject* func(DirEntry *self, PyObject *args, PyObject *kwargs)
becomes:
   PyObject* func(DirEntry *self, PyObject **args, int nargs, PyObject *kwargs)

Using METH_VARARGS, args is a Python tuple. Using METH_FASTCALL, args is a C array of PyObject*, and there is a second nargs parameter.

Later, Argument Clinic will be modified to *generate* code using the new METH_FASTCALL calling convention. Code written with Argument Clinic will only need to be updated by Argument Clinic to get the new faster calling convention (avoid the creation of a temporary tuple for positional arguments).

This issue depends on the issue #27809 "_PyObject_FastCall(): add support for keyword arguments". I will wait until this dependency is implemented, before working on the implementation of this part.

For a full implementation, see my first attempt in the issue #26814. I will extract the code from this branch to write a new patch.

----------
messages: 273173
nosy: haypo
priority: normal
severity: normal
status: open
title: Add METH_FASTCALL: new calling convention for C functions
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27810>
_______________________________________


More information about the New-bugs-announce mailing list