@@ -2121,20 +2121,20 @@ PyDoc_STRVAR(builtin_sorted__doc__,
2121
2121
"reverse flag can be set to request the result in descending order." );
2122
2122
2123
2123
#define BUILTIN_SORTED_METHODDEF \
2124
- {"sorted", (PyCFunction)builtin_sorted, METH_VARARGS|METH_KEYWORDS , builtin_sorted__doc__},
2124
+ {"sorted", (PyCFunction)builtin_sorted, METH_FASTCALL , builtin_sorted__doc__},
2125
2125
2126
2126
static PyObject *
2127
- builtin_sorted (PyObject * self , PyObject * args , PyObject * kwds )
2127
+ builtin_sorted (PyObject * self , PyObject * * args , Py_ssize_t nargs , PyObject * kwnames )
2128
2128
{
2129
- PyObject * newlist , * v , * seq , * keyfunc = NULL , * * newargs ;
2129
+ PyObject * newlist , * v , * seq , * keyfunc = NULL ;
2130
2130
PyObject * callable ;
2131
- static char * kwlist [] = {"iterable" , "key" , "reverse" , 0 };
2131
+ static const char * const kwlist [] = {"iterable" , "key" , "reverse" , 0 };
2132
+ /* args 1-3 should match listsort in Objects/listobject.c */
2133
+ static _PyArg_Parser parser = {"O|Oi:sorted" , kwlist , 0 };
2132
2134
int reverse ;
2133
- Py_ssize_t nargs ;
2134
2135
2135
- /* args 1-3 should match listsort in Objects/listobject.c */
2136
- if (!PyArg_ParseTupleAndKeywords (args , kwds , "O|Oi:sorted" ,
2137
- kwlist , & seq , & keyfunc , & reverse ))
2136
+ if (!_PyArg_ParseStackAndKeywords (args , nargs , kwnames , & parser ,
2137
+ & seq , & keyfunc , & reverse ))
2138
2138
return NULL ;
2139
2139
2140
2140
newlist = PySequence_List (seq );
@@ -2147,9 +2147,7 @@ builtin_sorted(PyObject *self, PyObject *args, PyObject *kwds)
2147
2147
return NULL ;
2148
2148
}
2149
2149
2150
- newargs = & PyTuple_GET_ITEM (args , 1 );
2151
- nargs = PyTuple_GET_SIZE (args ) - 1 ;
2152
- v = _PyObject_FastCallDict (callable , newargs , nargs , kwds );
2150
+ v = _PyObject_FastCallKeywords (callable , args + 1 , nargs - 1 , kwnames );
2153
2151
Py_DECREF (callable );
2154
2152
if (v == NULL ) {
2155
2153
Py_DECREF (newlist );
0 commit comments