]> granicus.if.org Git - python/commitdiff
Don't use true division where int division was intended. For that matter,
authorTim Peters <tim.peters@gmail.com>
Fri, 2 Aug 2002 19:16:44 +0000 (19:16 +0000)
committerTim Peters <tim.peters@gmail.com>
Fri, 2 Aug 2002 19:16:44 +0000 (19:16 +0000)
don't use division at all.

Lib/heapq.py
Lib/test/test_heapq.py

index cdba693b6ded9f7b088d4fd9ade8033696fa94fb..6264700ee4f96f8837b60aa9e8ccc77e0b2f3da0 100644 (file)
@@ -126,7 +126,7 @@ def heappush(heap, item):
     pos = len(heap)
     heap.append(None)
     while pos:
-        parentpos = (pos - 1) / 2
+        parentpos = (pos - 1) >> 1
         parent = heap[parentpos]
         if item >= parent:
             break
index 43723f33f650709c8d0002fcb52fcbee8567adc8..016fd3af41edbb024afed3d91d5c8bf268033940 100644 (file)
@@ -8,7 +8,7 @@ import random
 def check_invariant(heap):
     # Check the heap invariant.
     for pos, item in enumerate(heap):
-        parentpos = (pos+1)/2 - 1
+        parentpos = ((pos+1) >> 1) - 1
         if parentpos >= 0:
             verify(heap[parentpos] <= item)