diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-01-11 16:01:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-11 16:01:42 (GMT) |
commit | 2a39d251f07d4c620e3b9a1848e3d1eb3067be64 (patch) | |
tree | 23c1e8e63e57945fab6127d31800b7578795e14b /Modules/clinic/_gdbmmodule.c.h | |
parent | 4fa9591025b6a098f3d6402e5413ee6740ede6c5 (diff) | |
download | cpython-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 'Modules/clinic/_gdbmmodule.c.h')
-rw-r--r-- | Modules/clinic/_gdbmmodule.c.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Modules/clinic/_gdbmmodule.c.h b/Modules/clinic/_gdbmmodule.c.h index 9475264..15f47dc 100644 --- a/Modules/clinic/_gdbmmodule.c.h +++ b/Modules/clinic/_gdbmmodule.c.h @@ -21,11 +21,15 @@ _gdbm_gdbm_get(dbmobject *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 = _gdbm_gdbm_get_impl(self, key, default_value); exit: @@ -52,11 +56,15 @@ _gdbm_gdbm_setdefault(dbmobject *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 = _gdbm_gdbm_setdefault_impl(self, key, default_value); exit: @@ -290,4 +298,4 @@ skip_optional: exit: return return_value; } -/*[clinic end generated code: output=05f06065d2dc1f9e input=a9049054013a1b77]*/ +/*[clinic end generated code: output=0a72598e5a3acd60 input=a9049054013a1b77]*/ |