[Python-checkins] cpython: getattr() uses METH_FASTCALL

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


https://hg.python.org/cpython/rev/cda7d59d753b
changeset:   106200:cda7d59d753b
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Jan 17 03:52:27 2017 +0100
summary:
  getattr() uses METH_FASTCALL

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


diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -993,14 +993,19 @@
 
 /* AC: cannot convert yet, as needs PEP 457 group support in inspect */
 static PyObject *
-builtin_getattr(PyObject *self, PyObject *args)
+builtin_getattr(PyObject *self, PyObject **args, Py_ssize_t nargs,
+                PyObject *kwnames)
 {
     PyObject *v, *result, *dflt = NULL;
     PyObject *name;
 
-    if (!PyArg_UnpackTuple(args, "getattr", 2, 3, &v, &name, &dflt))
+    if (!_PyArg_UnpackStack(args, nargs, "getattr", 2, 3, &v, &name, &dflt))
         return NULL;
 
+    if (!_PyArg_NoStackKeywords("getattr", kwnames)) {
+        return NULL;
+    }
+
     if (!PyUnicode_Check(name)) {
         PyErr_SetString(PyExc_TypeError,
                         "getattr(): attribute name must be string");
@@ -2622,7 +2627,7 @@
     BUILTIN_EVAL_METHODDEF
     BUILTIN_EXEC_METHODDEF
     BUILTIN_FORMAT_METHODDEF
-    {"getattr",         builtin_getattr,    METH_VARARGS, getattr_doc},
+    {"getattr",         (PyCFunction)builtin_getattr, METH_FASTCALL, getattr_doc},
     BUILTIN_GLOBALS_METHODDEF
     BUILTIN_HASATTR_METHODDEF
     BUILTIN_HASH_METHODDEF

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


More information about the Python-checkins mailing list