yayy this is so much clearer to work off of: def content_generator(): # need updates by idx next_idx, next_keyhash, next_item = updates.pop() if len(updates) else [float('inf'),None,None] def keyhash2subidx(keyhash): wholeidx = int.from_bytes(keyhash[:hashbytes], 'big') assert superidx == wholeidx >> (hashbytes * 8 - self._hashbits) subidx = (wholeidx >> hashshift) & expansionmask assert superidx * expansion + subidx == wholeidx >> hashshift return subidx
for superidx, item in enumerate(tqdm.tqdm(self.array, desc='growing sentinel hashtable', leave=False)): update_chunk = [] while next_idx == superidx: next_subidx = keyhash2subidx(next_keyhash) next_idx, next_keyhash, next_item = updates.pop() if len(updates) else [float('inf'),None,None] if i can ignore the nested function then it's just like 4-6 lines of code to think about