[Python-checkins] cpython: next() uses FASTCALL

victor.stinner python-checkins at python.org
Tue Jan 17 09:25:11 EST 2017


https://hg.python.org/cpython/rev/1a7c9a95a964
changeset:   106201:1a7c9a95a964
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jan 17 04:09:14 2017 +0100
summary:
  next() uses FASTCALL

files:
  Python/bltinmodule.c |  12 +++++++++---
  1 files changed, 9 insertions(+), 3 deletions(-)


diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1303,13 +1303,19 @@
 
 /* AC: cannot convert yet, as needs PEP 457 group support in inspect */
 static PyObject *
-builtin_next(PyObject *self, PyObject *args)
+builtin_next(PyObject *self, PyObject **args, Py_ssize_t nargs,
+             PyObject *kwnames)
 {
     PyObject *it, *res;
     PyObject *def = NULL;
 
-    if (!PyArg_UnpackTuple(args, "next", 1, 2, &it, &def))
+    if (!_PyArg_UnpackStack(args, nargs, "next", 1, 2, &it, &def))
         return NULL;
+
+    if (!_PyArg_NoStackKeywords("next", kwnames)) {
+        return NULL;
+    }
+
     if (!PyIter_Check(it)) {
         PyErr_Format(PyExc_TypeError,
             "'%.200s' object is not an iterator",
@@ -2641,7 +2647,7 @@
     BUILTIN_LOCALS_METHODDEF
     {"max",             (PyCFunction)builtin_max,        METH_VARARGS | METH_KEYWORDS, max_doc},
     {"min",             (PyCFunction)builtin_min,        METH_VARARGS | METH_KEYWORDS, min_doc},
-    {"next",            (PyCFunction)builtin_next,       METH_VARARGS, next_doc},
+    {"next",            (PyCFunction)builtin_next,       METH_FASTCALL, next_doc},
     BUILTIN_OCT_METHODDEF
     BUILTIN_ORD_METHODDEF
     BUILTIN_POW_METHODDEF

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list