[Python-checkins] cpython: Convert one more division to unsigned arithmetic to speed-up deque_item().

raymond.hettinger python-checkins at python.org
Sat Feb 28 16:41:37 CET 2015


https://hg.python.org/cpython/rev/5942fd9ab335
changeset:   94786:5942fd9ab335
user:        Raymond Hettinger <python at rcn.com>
date:        Sat Feb 28 07:41:30 2015 -0800
summary:
  Convert one more division to unsigned arithmetic to speed-up deque_item().

files:
  Modules/_collectionsmodule.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -788,7 +788,9 @@
             while (n--)
                 b = b->rightlink;
         } else {
-            n = (deque->leftindex + Py_SIZE(deque) - 1) / BLOCKLEN - n;
+            n = (Py_ssize_t)(
+                    ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+                    / BLOCKLEN - n);
             b = deque->rightblock;
             while (n--)
                 b = b->leftlink;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list