11308: Fix bytes vs. str problems.
[arvados.git] / sdk / python / arvados / _ranges.py
index 83437b2adb9f7817ac0b5ee210cfdb6d50915b90..6d7c112b99b8dc8818ef8f3a1988f6200117248c 100644 (file)
@@ -1,3 +1,5 @@
+from __future__ import division
+from builtins import object
 import logging
 
 _logger = logging.getLogger('arvados.ranges')
@@ -6,6 +8,8 @@ _logger = logging.getLogger('arvados.ranges')
 RANGES_SPAM = 9
 
 class Range(object):
+    __slots__ = ("locator", "range_start", "range_size", "segment_offset")
+
     def __init__(self, locator, range_start, range_size, segment_offset=0):
         self.locator = locator
         self.range_start = range_start
@@ -22,14 +26,14 @@ class Range(object):
                 self.segment_offset == other.segment_offset)
 
 def first_block(data_locators, range_start):
-    block_start = 0L
+    block_start = 0
 
     # range_start/block_start is the inclusive lower bound
     # range_end/block_end is the exclusive upper bound
 
     hi = len(data_locators)
     lo = 0
-    i = int((hi + lo) / 2)
+    i = (hi + lo) // 2
     block_size = data_locators[i].range_size
     block_start = data_locators[i].range_start
     block_end = block_start + block_size
@@ -45,7 +49,7 @@ def first_block(data_locators, range_start):
             lo = i
         else:
             hi = i
-        i = int((hi + lo) / 2)
+        i = (hi + lo) // 2
         block_size = data_locators[i].range_size
         block_start = data_locators[i].range_start
         block_end = block_start + block_size
@@ -53,6 +57,8 @@ def first_block(data_locators, range_start):
     return i
 
 class LocatorAndRange(object):
+    __slots__ = ("locator", "block_size", "segment_offset", "segment_size")
+
     def __init__(self, locator, block_size, segment_offset, segment_size):
         self.locator = locator
         self.block_size = block_size