[Python-checkins] cpython: Precomputing the number iterations allows the inner-loop to be vectorizable.
raymond.hettinger
python-checkins at python.org
Sat Sep 26 11:14:55 CEST 2015
https://hg.python.org/cpython/rev/821eca6e5a33
changeset: 98283:821eca6e5a33
user: Raymond Hettinger <python at rcn.com>
date: Sat Sep 26 02:14:50 2015 -0700
summary:
Precomputing the number iterations allows the inner-loop to be vectorizable.
files:
Modules/_collectionsmodule.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -557,7 +557,7 @@
static PyObject *
deque_inplace_repeat(dequeobject *deque, Py_ssize_t n)
{
- Py_ssize_t i, size;
+ Py_ssize_t i, m, size;
PyObject *seq;
PyObject *rv;
@@ -598,7 +598,11 @@
MARK_END(b->rightlink);
deque->rightindex = -1;
}
- for ( ; i < n-1 && deque->rightindex != BLOCKLEN - 1 ; i++) {
+ m = n - 1 - i;
+ if (m > BLOCKLEN - 1 - deque->rightindex)
+ m = BLOCKLEN - 1 - deque->rightindex;
+ i += m;
+ while (m--) {
deque->rightindex++;
Py_INCREF(item);
deque->rightblock->data[deque->rightindex] = item;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list