summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-11-10 04:28:31 (GMT)
committerGitHub <noreply@github.com>2019-11-10 04:28:31 (GMT)
commitaf46450bb97ab9bd38748e75aa849c29fdd70028 (patch)
tree17f39f9c3db6d4816eef47d87e54f8d49768a52b /Modules
parente27449da92b13730a5e11182f329d5da98a5e05b (diff)
downloadcpython-af46450bb97ab9bd38748e75aa849c29fdd70028.zip
cpython-af46450bb97ab9bd38748e75aa849c29fdd70028.tar.gz
cpython-af46450bb97ab9bd38748e75aa849c29fdd70028.tar.bz2
Minor readability improvement for argument handling in itertools.repeat() (GH-17101)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/itertoolsmodule.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c
index 3d39fa2..0cb4729 100644
--- a/Modules/itertoolsmodule.c
+++ b/Modules/itertoolsmodule.c
@@ -4256,17 +4256,17 @@ repeat_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
repeatobject *ro;
PyObject *element;
- Py_ssize_t cnt = -1, n_kwds = 0;
+ Py_ssize_t cnt = -1, n_args;
static char *kwargs[] = {"object", "times", NULL};
+ n_args = PyTuple_GET_SIZE(args);
+ if (kwds != NULL)
+ n_args += PyDict_GET_SIZE(kwds);
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:repeat", kwargs,
&element, &cnt))
return NULL;
-
- if (kwds != NULL)
- n_kwds = PyDict_GET_SIZE(kwds);
/* Does user supply times argument? */
- if ((PyTuple_Size(args) + n_kwds == 2) && cnt < 0)
+ if (n_args == 2 && cnt < 0)
cnt = 0;
ro = (repeatobject *)type->tp_alloc(type, 0);