Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e90bdb1

Browse files
committed
Issue #27830: Revert, remove _PyFunction_FastCallKeywords()
1 parent bb10859 commit e90bdb1

4 files changed

Lines changed: 6 additions & 74 deletions

File tree

Include/abstract.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -292,23 +292,6 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
292292
#define _PyObject_CallArg1(func, arg) \
293293
_PyObject_FastCall((func), &(arg), 1)
294294

295-
/* Call the callable object func with the "fast call" calling convention:
296-
args is a C array for positional arguments followed by (key, value)
297-
pairs for keyword arguments.
298-
299-
nargs is the number of positional parameters at the beginning of stack.
300-
nkwargs is the number of (key, value) pairs at the end of stack.
301-
302-
If nargs and nkwargs are equal to zero, stack can be NULL.
303-
304-
Return the result on success. Raise an exception and return NULL on
305-
error. */
306-
PyAPI_FUNC(PyObject *) _PyObject_FastCallKeywords(
307-
PyObject *func,
308-
PyObject **stack,
309-
Py_ssize_t nargs,
310-
Py_ssize_t nkwargs);
311-
312295
PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(PyObject *func,
313296
PyObject *obj, PyObject *args,
314297
PyObject *kwargs);

Include/funcobject.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict(
6464
PyObject **args,
6565
Py_ssize_t nargs,
6666
PyObject *kwargs);
67-
68-
PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords(
69-
PyObject *func,
70-
PyObject **stack,
71-
Py_ssize_t nargs,
72-
Py_ssize_t nkwargs);
7367
#endif
7468

7569
/* Macros for direct access to these values. Type checks are *not*

Objects/abstract.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,51 +2343,6 @@ _PyStack_AsDict(PyObject **stack, Py_ssize_t nkwargs, PyObject *func)
23432343
return kwdict;
23442344
}
23452345

2346-
PyObject *
2347-
_PyObject_FastCallKeywords(PyObject *func, PyObject **stack, Py_ssize_t nargs,
2348-
Py_ssize_t nkwargs)
2349-
{
2350-
PyObject *args, *kwdict, *result;
2351-
2352-
/* _PyObject_FastCallKeywords() must not be called with an exception set,
2353-
because it may clear it (directly or indirectly) and so the
2354-
caller loses its exception */
2355-
assert(!PyErr_Occurred());
2356-
2357-
assert(func != NULL);
2358-
assert(nargs >= 0);
2359-
assert(nkwargs >= 0);
2360-
assert((nargs == 0 && nkwargs == 0) || stack != NULL);
2361-
2362-
if (PyFunction_Check(func)) {
2363-
/* Fast-path: avoid temporary tuple or dict */
2364-
return _PyFunction_FastCallKeywords(func, stack, nargs, nkwargs);
2365-
}
2366-
2367-
if (PyCFunction_Check(func) && nkwargs == 0) {
2368-
return _PyCFunction_FastCallDict(func, stack, nargs, NULL);
2369-
}
2370-
2371-
/* Slow-path: build temporary tuple and/or dict */
2372-
args = _PyStack_AsTuple(stack, nargs);
2373-
2374-
if (nkwargs > 0) {
2375-
kwdict = _PyStack_AsDict(stack + nargs, nkwargs, func);
2376-
if (kwdict == NULL) {
2377-
Py_DECREF(args);
2378-
return NULL;
2379-
}
2380-
}
2381-
else {
2382-
kwdict = NULL;
2383-
}
2384-
2385-
result = PyObject_Call(func, args, kwdict);
2386-
Py_DECREF(args);
2387-
Py_XDECREF(kwdict);
2388-
return result;
2389-
}
2390-
23912346
/* Positional arguments are obj followed args. */
23922347
PyObject *
23932348
_PyObject_Call_Prepend(PyObject *func,

Python/ceval.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ static PyObject * call_function(PyObject ***, int, uint64*, uint64*);
113113
#else
114114
static PyObject * call_function(PyObject ***, int);
115115
#endif
116+
static PyObject * fast_function(PyObject *, PyObject **, Py_ssize_t, Py_ssize_t);
116117
static PyObject * do_call(PyObject *, PyObject ***, Py_ssize_t, Py_ssize_t);
117118
static PyObject * ext_do_call(PyObject *, PyObject ***, int, Py_ssize_t, Py_ssize_t);
118119
static PyObject * update_keyword_args(PyObject *, Py_ssize_t, PyObject ***,
@@ -4766,7 +4767,7 @@ call_function(PyObject ***pp_stack, int oparg
47664767
}
47674768
READ_TIMESTAMP(*pintr0);
47684769
if (PyFunction_Check(func)) {
4769-
x = _PyFunction_FastCallKeywords(func, (*pp_stack) - n, nargs, nkwargs);
4770+
x = fast_function(func, (*pp_stack) - n, nargs, nkwargs);
47704771
}
47714772
else {
47724773
x = do_call(func, pp_stack, nargs, nkwargs);
@@ -4779,7 +4780,7 @@ call_function(PyObject ***pp_stack, int oparg
47794780

47804781
/* Clear the stack of the function object. Also removes
47814782
the arguments in case they weren't consumed already
4782-
(_PyFunction_FastCallKeywords() and err_args() leave them on the stack).
4783+
(fast_function() and err_args() leave them on the stack).
47834784
*/
47844785
while ((*pp_stack) > pfunc) {
47854786
w = EXT_POP(*pp_stack);
@@ -4791,7 +4792,7 @@ call_function(PyObject ***pp_stack, int oparg
47914792
return x;
47924793
}
47934794

4794-
/* The _PyFunction_FastCallKeywords() function optimize calls for which no argument
4795+
/* The fast_function() function optimize calls for which no argument
47954796
tuple is necessary; the objects are passed directly from the stack.
47964797
For the simplest case -- a function that takes only positional
47974798
arguments and is called with only positional arguments -- it
@@ -4839,9 +4840,8 @@ _PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t nargs,
48394840

48404841
/* Similar to _PyFunction_FastCall() but keywords are passed a (key, value)
48414842
pairs in stack */
4842-
PyObject *
4843-
_PyFunction_FastCallKeywords(PyObject *func, PyObject **stack,
4844-
Py_ssize_t nargs, Py_ssize_t nkwargs)
4843+
static PyObject *
4844+
fast_function(PyObject *func, PyObject **stack, Py_ssize_t nargs, Py_ssize_t nkwargs)
48454845
{
48464846
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
48474847
PyObject *globals = PyFunction_GET_GLOBALS(func);

0 commit comments

Comments
 (0)