summaryrefslogtreecommitdiff
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 220c92ddc5..1cdc0e2563 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2087,10 +2087,11 @@ PyDoc_STRVAR(builtin_sorted__doc__,
static PyObject *
builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
{
- PyObject *newlist, *v, *seq, *keyfunc=NULL, *newargs;
+ PyObject *newlist, *v, *seq, *keyfunc=NULL, **newargs;
PyObject *callable;
static char *kwlist[] = {"iterable", "key", "reverse", 0};
int reverse;
+ int nargs;
/* args 1-3 should match listsort in Objects/listobject.c */
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|Oi:sorted",
@@ -2107,15 +2108,9 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
return NULL;
}
- newargs = PyTuple_GetSlice(args, 1, 4);
- if (newargs == NULL) {
- Py_DECREF(newlist);
- Py_DECREF(callable);
- return NULL;
- }
-
- v = PyObject_Call(callable, newargs, kwds);
- Py_DECREF(newargs);
+ newargs = &PyTuple_GET_ITEM(args, 1);
+ nargs = PyTuple_GET_SIZE(args) - 1;
+ v = _PyObject_FastCallDict(callable, newargs, nargs, kwds);
Py_DECREF(callable);
if (v == NULL) {
Py_DECREF(newlist);