Skip to content

Commit 5954334

Browse files
jdemeyermethane
authored andcommitted
bpo-37151: remove _PyFunction_FastCallDict (GH-13864)
1 parent d8f336f commit 5954334

File tree

3 files changed

+1
-106
lines changed

3 files changed

+1
-106
lines changed

‎Include/funcobject.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *);
6060
PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
6161

6262
#ifndef Py_LIMITED_API
63-
PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict(
64-
PyObject *func,
65-
PyObject *const *args,
66-
Py_ssize_t nargs,
67-
PyObject *kwargs);
68-
6963
PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
7064
PyObject *func,
7165
PyObject *const *stack,

‎Objects/call.c‎

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -303,94 +303,6 @@ function_code_fastcall(PyCodeObject *co, PyObject *const *args, Py_ssize_t nargs
303303
}
304304

305305

306-
PyObject *
307-
_PyFunction_FastCallDict(PyObject *func, PyObject *const *args, Py_ssize_t nargs,
308-
PyObject *kwargs)
309-
{
310-
PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
311-
PyObject *globals = PyFunction_GET_GLOBALS(func);
312-
PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
313-
PyObject *kwdefs, *closure, *name, *qualname;
314-
PyObject *kwtuple, **k;
315-
PyObject **d;
316-
Py_ssize_t nd, nk;
317-
PyObject *result;
318-
319-
assert(func != NULL);
320-
assert(nargs >= 0);
321-
assert(nargs == 0 || args != NULL);
322-
assert(kwargs == NULL || PyDict_Check(kwargs));
323-
324-
if (co->co_kwonlyargcount == 0 &&
325-
(kwargs == NULL || PyDict_GET_SIZE(kwargs) == 0) &&
326-
(co->co_flags & ~PyCF_MASK) == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE))
327-
{
328-
/* Fast paths */
329-
if (argdefs == NULL && co->co_argcount == nargs) {
330-
return function_code_fastcall(co, args, nargs, globals);
331-
}
332-
else if (nargs == 0 && argdefs != NULL
333-
&& co->co_argcount == PyTuple_GET_SIZE(argdefs)) {
334-
/* function called with no arguments, but all parameters have
335-
a default value: use default values as arguments .*/
336-
args = _PyTuple_ITEMS(argdefs);
337-
return function_code_fastcall(co, args, PyTuple_GET_SIZE(argdefs),
338-
globals);
339-
}
340-
}
341-
342-
nk = (kwargs != NULL) ? PyDict_GET_SIZE(kwargs) : 0;
343-
if (nk != 0) {
344-
Py_ssize_t pos, i;
345-
346-
/* bpo-29318, bpo-27840: Caller and callee functions must not share
347-
the dictionary: kwargs must be copied. */
348-
kwtuple = PyTuple_New(2 * nk);
349-
if (kwtuple == NULL) {
350-
return NULL;
351-
}
352-
353-
k = _PyTuple_ITEMS(kwtuple);
354-
pos = i = 0;
355-
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
356-
/* We must hold strong references because keyword arguments can be
357-
indirectly modified while the function is called:
358-
see issue #2016 and test_extcall */
359-
Py_INCREF(k[i]);
360-
Py_INCREF(k[i+1]);
361-
i += 2;
362-
}
363-
assert(i / 2 == nk);
364-
}
365-
else {
366-
kwtuple = NULL;
367-
k = NULL;
368-
}
369-
370-
kwdefs = PyFunction_GET_KW_DEFAULTS(func);
371-
closure = PyFunction_GET_CLOSURE(func);
372-
name = ((PyFunctionObject *)func) -> func_name;
373-
qualname = ((PyFunctionObject *)func) -> func_qualname;
374-
375-
if (argdefs != NULL) {
376-
d = _PyTuple_ITEMS(argdefs);
377-
nd = PyTuple_GET_SIZE(argdefs);
378-
}
379-
else {
380-
d = NULL;
381-
nd = 0;
382-
}
383-
384-
result = _PyEval_EvalCodeWithName((PyObject*)co, globals, (PyObject *)NULL,
385-
args, nargs,
386-
k, k != NULL ? k + 1 : NULL, nk, 2,
387-
d, nd, kwdefs,
388-
closure, name, qualname);
389-
Py_XDECREF(kwtuple);
390-
return result;
391-
}
392-
393-
394306
PyObject *
395307
_PyFunction_Vectorcall(PyObject *func, PyObject* const* stack,
396308
size_t nargsf, PyObject *kwnames)

‎Objects/funcobject.c‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -622,17 +622,6 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg)
622622
return 0;
623623
}
624624

625-
static PyObject *
626-
function_call(PyObject *func, PyObject *args, PyObject *kwargs)
627-
{
628-
PyObject **stack;
629-
Py_ssize_t nargs;
630-
631-
stack = _PyTuple_ITEMS(args);
632-
nargs = PyTuple_GET_SIZE(args);
633-
return _PyFunction_FastCallDict(func, stack, nargs, kwargs);
634-
}
635-
636625
/* Bind a function to an object */
637626
static PyObject *
638627
func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
@@ -659,7 +648,7 @@ PyTypeObject PyFunction_Type = {
659648
0, /* tp_as_sequence */
660649
0, /* tp_as_mapping */
661650
0, /* tp_hash */
662-
function_call, /* tp_call */
651+
PyVectorcall_Call, /* tp_call */
663652
0, /* tp_str */
664653
0, /* tp_getattro */
665654
0, /* tp_setattro */

0 commit comments

Comments
 (0)