Clean up, remove compat with py < 3.6
[pyi2ncommon] / src / buffers.py
index d0588d2..aa79de3 100644 (file)
 buffers.py: buffers of various shapes, sizes and functionalities
 
 Featuring::
-
-* CircularBuffer
-* LogarithmicBuffer: saves only last N items, and after that less and less so
-*                    very few old items are kept
+    - CircularBuffer
+    - LogarithmicBuffer: saves only last N items, and after that less and less so
+                         very few old items are kept
 """
 
+
 class CircularBuffer:
     """ circular buffer for data; saves last N sets
 
@@ -46,7 +46,7 @@ class CircularBuffer:
         if size < 1:
             raise ValueError('size must be positive!')
         self.buffer_size = size
-        self._buffer = [empty_element for idx in range(size)]
+        self._buffer = [empty_element for _ in range(size)]
         self._buff_idx = 0
         self.n_items = 0
 
@@ -119,7 +119,7 @@ class LogarithmicBuffer:
         """ internal helper for saving (or not) items in data_old """
 
         # determine whether we throw it away or actually save it
-        if age % 2**index != 0:
+        if age % 2 ** index != 0:
             return
 
         # we save it. But before check if we need to extend data_old or
@@ -127,7 +127,7 @@ class LogarithmicBuffer:
         if len(self._data_old) <= index:
             self._data_old.append(item)
         else:
-            self._save_old(self._data_old[index], age, index+1)
+            self._save_old(self._data_old[index], age, index + 1)
             self._data_old[index] = item
 
     def get_all(self):