mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-29735: Optimize partial_call(): avoid tuple (#516)
* Add _PyObject_HasFastCall() * partial_call() now avoids temporary tuple to pass positional arguments if the callable supports the FASTCALL calling convention for positional arguments. * Fix also a performance regression in partial_call() if the callable doesn't support FASTCALL.
This commit is contained in:
parent
d4914e9041
commit
0f7b0b397e
3 changed files with 105 additions and 40 deletions
|
@ -2,6 +2,22 @@
|
|||
#include "frameobject.h"
|
||||
|
||||
|
||||
int
|
||||
_PyObject_HasFastCall(PyObject *callable)
|
||||
{
|
||||
if (PyFunction_Check(callable)) {
|
||||
return 1;
|
||||
}
|
||||
else if (PyCFunction_Check(callable)) {
|
||||
return !(PyCFunction_GET_FLAGS(callable) & METH_VARARGS);
|
||||
}
|
||||
else {
|
||||
assert (PyCallable_Check(callable));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static PyObject *
|
||||
null_error(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue