summaryrefslogtreecommitdiffstats
path: root/Objects/clinic/complexobject.c.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-03-14 08:32:22 (GMT)
committerGitHub <noreply@github.com>2019-03-14 08:32:22 (GMT)
commit3191391515824fa7f3c573d807f1034c6a28fab3 (patch)
treeff8213b07b206de4df88dc352ee957ce68f0f2de /Objects/clinic/complexobject.c.h
parent2c0d3f454705bb5ccf5f6189f3cf77bbae4f056b (diff)
downloadcpython-3191391515824fa7f3c573d807f1034c6a28fab3.zip
cpython-3191391515824fa7f3c573d807f1034c6a28fab3.tar.gz
cpython-3191391515824fa7f3c573d807f1034c6a28fab3.tar.bz2
bpo-36127: Argument Clinic: inline parsing code for keyword parameters. (GH-12058)
Diffstat (limited to 'Objects/clinic/complexobject.c.h')
-rw-r--r--Objects/clinic/complexobject.c.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/Objects/clinic/complexobject.c.h b/Objects/clinic/complexobject.c.h
index 0cbfb79..8caa910 100644
--- a/Objects/clinic/complexobject.c.h
+++ b/Objects/clinic/complexobject.c.h
@@ -18,17 +18,32 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"real", "imag", NULL};
- static _PyArg_Parser _parser = {"|OO:complex", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "complex", 0};
+ PyObject *argsbuf[2];
+ PyObject * const *fastargs;
+ Py_ssize_t nargs = PyTuple_GET_SIZE(args);
+ Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 0;
PyObject *r = _PyLong_Zero;
PyObject *i = NULL;
- if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
- &r, &i)) {
+ fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 0, 2, 0, argsbuf);
+ if (!fastargs) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (fastargs[0]) {
+ r = fastargs[0];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ i = fastargs[1];
+skip_optional_pos:
return_value = complex_new_impl(type, r, i);
exit:
return return_value;
}
-/*[clinic end generated code: output=5017b2458bdc4ecd input=a9049054013a1b77]*/
+/*[clinic end generated code: output=a0fe23fdbdc9b06b input=a9049054013a1b77]*/