diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-30 06:09:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 06:09:41 (GMT) |
commit | ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb (patch) | |
tree | fe0766c34601880610c3399a8f01c35ab6e8fe8e /Modules/itertoolsmodule.c | |
parent | e6911a44f69c0d302db60f49952a9cf69da69a2b (diff) | |
download | cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.zip cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.gz cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.bz2 |
bpo-29878: Add global instances of int for 0 and 1. (#852)
Diffstat (limited to 'Modules/itertoolsmodule.c')
-rw-r--r-- | Modules/itertoolsmodule.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/Modules/itertoolsmodule.c b/Modules/itertoolsmodule.c index f867252..e91a029 100644 --- a/Modules/itertoolsmodule.c +++ b/Modules/itertoolsmodule.c @@ -3965,24 +3965,16 @@ count_new(PyTypeObject *type, PyObject *args, PyObject *kwds) fast_mode = 0; } } - Py_INCREF(long_cnt); } else { cnt = 0; - long_cnt = PyLong_FromLong(0); - if (long_cnt == NULL) { - return NULL; - } + long_cnt = _PyLong_Zero; } + Py_INCREF(long_cnt); /* If not specified, step defaults to 1 */ - if (long_step == NULL) { - long_step = PyLong_FromLong(1); - if (long_step == NULL) { - Py_DECREF(long_cnt); - return NULL; - } - } else - Py_INCREF(long_step); + if (long_step == NULL) + long_step = _PyLong_One; + Py_INCREF(long_step); assert(long_cnt != NULL && long_step != NULL); |