summaryrefslogtreecommitdiffstats
path: root/Objects/clinic/dictobject.c.h
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-01-11 16:01:42 (GMT)
committerGitHub <noreply@github.com>2019-01-11 16:01:42 (GMT)
commit2a39d251f07d4c620e3b9a1848e3d1eb3067be64 (patch)
tree23c1e8e63e57945fab6127d31800b7578795e14b /Objects/clinic/dictobject.c.h
parent4fa9591025b6a098f3d6402e5413ee6740ede6c5 (diff)
downloadcpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.zip
cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.gz
cpython-2a39d251f07d4c620e3b9a1848e3d1eb3067be64.tar.bz2
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.
Diffstat (limited to 'Objects/clinic/dictobject.c.h')
-rw-r--r--Objects/clinic/dictobject.c.h32
1 files changed, 22 insertions, 10 deletions
diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h
index 5db3a42..713781c 100644
--- a/Objects/clinic/dictobject.c.h
+++ b/Objects/clinic/dictobject.c.h
@@ -21,11 +21,15 @@ dict_fromkeys(PyTypeObject *type, PyObject *const *args, Py_ssize_t nargs)
PyObject *iterable;
PyObject *value = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "fromkeys",
- 1, 2,
- &iterable, &value)) {
+ if (!_PyArg_CheckPositional("fromkeys", nargs, 1, 2)) {
goto exit;
}
+ iterable = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ value = args[1];
+skip_optional:
return_value = dict_fromkeys_impl(type, iterable, value);
exit:
@@ -60,11 +64,15 @@ dict_get(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *key;
PyObject *default_value = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "get",
- 1, 2,
- &key, &default_value)) {
+ if (!_PyArg_CheckPositional("get", nargs, 1, 2)) {
goto exit;
}
+ key = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ default_value = args[1];
+skip_optional:
return_value = dict_get_impl(self, key, default_value);
exit:
@@ -93,11 +101,15 @@ dict_setdefault(PyDictObject *self, PyObject *const *args, Py_ssize_t nargs)
PyObject *key;
PyObject *default_value = Py_None;
- if (!_PyArg_UnpackStack(args, nargs, "setdefault",
- 1, 2,
- &key, &default_value)) {
+ if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) {
goto exit;
}
+ key = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ default_value = args[1];
+skip_optional:
return_value = dict_setdefault_impl(self, key, default_value);
exit:
@@ -121,4 +133,4 @@ dict___reversed__(PyDictObject *self, PyObject *Py_UNUSED(ignored))
{
return dict___reversed___impl(self);
}
-/*[clinic end generated code: output=193e08cb8099fe22 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=12c21ce3552d9617 input=a9049054013a1b77]*/