cpython: ffcfa4f005a3 (original) (raw)
Mercurial > cpython
changeset 102911:ffcfa4f005a3
Issue #27830: Revert, remove _PyFunction_FastCallKeywords() [#27830]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Thu, 25 Aug 2016 23:26:50 +0200 |
parents | a0a7c5b1af97 |
children | 10a73648c92c |
files | Include/abstract.h Include/funcobject.h Objects/abstract.c Python/ceval.c |
diffstat | 4 files changed, 6 insertions(+), 74 deletions(-)[+] [-] Include/abstract.h 17 Include/funcobject.h 6 Objects/abstract.c 45 Python/ceval.c 12 |
line wrap: on
line diff
--- a/Include/abstract.h +++ b/Include/abstract.h @@ -292,23 +292,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #define _PyObject_CallArg1(func, arg) [](#l1.4) _PyObject_FastCall((func), &(arg), 1)
/* Call the callable object func with the "fast call" calling convention:[](#l1.7)
args is a C array for positional arguments followed by (key, value)[](#l1.8)
pairs for keyword arguments.[](#l1.9)
nargs is the number of positional parameters at the beginning of stack.[](#l1.11)
nkwargs is the number of (key, value) pairs at the end of stack.[](#l1.12)
If nargs and nkwargs are equal to zero, stack can be NULL.[](#l1.14)
Return the result on success. Raise an exception and return NULL on[](#l1.16)
error. */[](#l1.17)
PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords([](#l1.18)
PyObject *func,[](#l1.19)
PyObject **stack,[](#l1.20)
Py_ssize_t nargs,[](#l1.21)
Py_ssize_t nkwargs);[](#l1.22)
- PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(PyObject *func, PyObject *obj, PyObject *args, PyObject *kwargs);
--- a/Include/funcobject.h +++ b/Include/funcobject.h @@ -64,12 +64,6 @@ PyAPI_FUNC(PyObject *) _PyFunction_FastC PyObject **args, Py_ssize_t nargs, PyObject *kwargs); - -PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords(
#endif /* Macros for direct access to these values. Type checks are not
--- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -2343,51 +2343,6 @@ static PyObject * return kwdict; } -PyObject * -_PyObject_FastCallKeywords(PyObject *func, PyObject **stack, Py_ssize_t nargs,
Py_ssize_t nkwargs)[](#l3.9)
- /* _PyObject_FastCallKeywords() must not be called with an exception set,
because it may clear it (directly or indirectly) and so the[](#l3.14)
caller loses its exception */[](#l3.15)
- assert(!PyErr_Occurred());
- assert(func != NULL);
- assert(nargs >= 0);
- assert(nkwargs >= 0);
- assert((nargs == 0 && nkwargs == 0) || stack != NULL);
- if (PyFunction_Check(func)) {
/* Fast-path: avoid temporary tuple or dict */[](#l3.24)
return _PyFunction_FastCallKeywords(func, stack, nargs, nkwargs);[](#l3.25)
- }
- if (PyCFunction_Check(func) && nkwargs == 0) {
return _PyCFunction_FastCallDict(func, stack, nargs, NULL);[](#l3.29)
- }
- if (nkwargs > 0) {
kwdict = _PyStack_AsDict(stack + nargs, nkwargs, func);[](#l3.36)
if (kwdict == NULL) {[](#l3.37)
Py_DECREF(args);[](#l3.38)
return NULL;[](#l3.39)
}[](#l3.40)
- }
- else {
kwdict = NULL;[](#l3.43)
- }
-} - /* Positional arguments are obj followed args. */ PyObject * _PyObject_Call_Prepend(PyObject *func,
--- a/Python/ceval.c +++ b/Python/ceval.c @@ -113,6 +113,7 @@ static PyObject * call_function(PyObject #else static PyObject * call_function(PyObject ***, int); #endif +static PyObject * fast_function(PyObject *, PyObject **, Py_ssize_t, Py_ssize_t); static PyObject * do_call(PyObject *, PyObject ***, Py_ssize_t, Py_ssize_t); static PyObject * ext_do_call(PyObject *, PyObject ***, int, Py_ssize_t, Py_ssize_t); static PyObject * update_keyword_args(PyObject *, Py_ssize_t, PyObject ***, @@ -4766,7 +4767,7 @@ call_function(PyObject ***pp_stack, int } READ_TIMESTAMP(*pintr0); if (PyFunction_Check(func)) {
x = _PyFunction_FastCallKeywords(func, (*pp_stack) - n, nargs, nkwargs);[](#l4.15)
x = fast_function(func, (*pp_stack) - n, nargs, nkwargs);[](#l4.16) }[](#l4.17) else {[](#l4.18) x = do_call(func, pp_stack, nargs, nkwargs);[](#l4.19)
@@ -4779,7 +4780,7 @@ call_function(PyObject **pp_stack, int / Clear the stack of the function object. Also removes the arguments in case they weren't consumed already
(_PyFunction_FastCallKeywords() and err_args() leave them on the stack).[](#l4.24)
while ((*pp_stack) > pfunc) { w = EXT_POP(*pp_stack);(fast_function() and err_args() leave them on the stack).[](#l4.25) */[](#l4.26)
@@ -4791,7 +4792,7 @@ call_function(PyObject pp_stack, int return x; } -/ The _PyFunction_FastCallKeywords() function optimize calls for which no argument +/ The fast_function() function optimize calls for which no argument tuple is necessary; the objects are passed directly from the stack. For the simplest case -- a function that takes only positional arguments and is called with only positional arguments -- it @@ -4839,9 +4840,8 @@ static PyObject /* Similar to _PyFunction_FastCall() but keywords are passed a (key, value) pairs in stack */ -PyObject * -_PyFunction_FastCallKeywords(PyObject *func, PyObject **stack,
Py_ssize_t nargs, Py_ssize_t nkwargs)[](#l4.44)
+static PyObject * +fast_function(PyObject *func, PyObject **stack, Py_ssize_t nargs, Py_ssize_t nkwargs) { PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); PyObject *globals = PyFunction_GET_GLOBALS(func);