From 2a39d251f07d4c620e3b9a1848e3d1eb3067be64 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Fri, 11 Jan 2019 18:01:42 +0200 Subject: bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520) Use _PyArg_CheckPositional() and inlined code instead of PyArg_UnpackTuple() and _PyArg_UnpackStack() if all parameters are positional and use the "object" converter. --- Objects/clinic/tupleobject.c.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Objects/clinic/tupleobject.c.h') diff --git a/Objects/clinic/tupleobject.c.h b/Objects/clinic/tupleobject.c.h index 0096f0cd0f..fe2fae42ee 100644 --- a/Objects/clinic/tupleobject.c.h +++ b/Objects/clinic/tupleobject.c.h @@ -81,11 +81,14 @@ tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) !_PyArg_NoKeywords("tuple", kwargs)) { goto exit; } - if (!PyArg_UnpackTuple(args, "tuple", - 0, 1, - &iterable)) { + if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) { goto exit; } + if (PyTuple_GET_SIZE(args) < 1) { + goto skip_optional; + } + iterable = PyTuple_GET_ITEM(args, 0); +skip_optional: return_value = tuple_new_impl(type, iterable); exit: @@ -108,4 +111,4 @@ tuple___getnewargs__(PyTupleObject *self, PyObject *Py_UNUSED(ignored)) { return tuple___getnewargs___impl(self); } -/*[clinic end generated code: output=5312868473a41cfe input=a9049054013a1b77]*/ +/*[clinic end generated code: output=56fab9b7368aba49 input=a9049054013a1b77]*/ -- cgit v1.2.1