[issue46323] Use _PyObject_Vectorcall in Modules/_ctypes/callbacks.c

hydroflask report at bugs.python.org
Sun Feb 6 19:19:02 EST 2022


hydroflask <hydroflask at yqxmail.com> added the comment:

@corona10

Thank you for looking into it.

The benchmark you did is not reflective of my use-case. I have a codebase that I have completely converted into a C extension using mypyc. So the ctypes callback does not call into interpreted Python code but actually another C-extension. I have annotated types aggressively to avoid invoking malloc(). In this use-case the extra overhead from the tuple allocation would be significant.

Additionally your benchmark may not be as micro as intended. You call some math in the callback function which may have made the savings from avoiding the tuple allocation seem more like noise.

Since you already did the work I still think it's worth putting it in since PyObject_Vectorcall is an established API and it would have been used anyway if this were written from scratch.

----------

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


More information about the Python-bugs-list mailing list