so, a possible net step for read_many would be to clean up section 3/3. first i'll paste how it looks, then the code it was likely ported from:
here's how it looks: tail = tails[idx] aligned_tail = aligned_tails[idx] aligned_offset = aligned_offsets[idx]#offset_length_tail_idx_ops[next_op_ct-1,TAIL] length = aligned_tail - aligned_offset assert next_hole <= aligned_offset next_hole = aligned_offset while next_data < tail: assert next_data - next_hole <= length length = next_data - next_hole offset_length_tail_idx_ops[op_ct,OFFSET] = next_hole offset_length_tail_idx_ops[op_ct,TAIL] = next_data offset_length_tail_idx_ops[op_ct,OP] = OP_FETCH | OP_PLACE op_ct += 1 cls.sparse_usage += length next_hole = self._next_sparse(next_data, os.SEEK_HOLE) next_data = self._next_sparse(next_hole, os.SEEK_DATA) if next_hole < tail: length = aligned_tail - next_hole offset_length_tail_idx_ops[next_op_ct,OFFSET] = next_hole offset_length_tail_idx_ops[next_op_ct,TAIL] = aligned_tail offset_length_tail_idx_ops[next_op_ct,OP] = OP_FETCH | OP_PLACE next_op_ct += 1 cls.sparse_usage += length next_hole = self._next_sparse(aligned_tail, os.SEEK_HOLE) offset_length_tail_idx_ops[op_ct:next_op_ct,LENGTH] = offset_length_tail_idx_ops[op_ct:next_op_ct,TAIL] offset_length_tail_idx_ops[op_ct:next_op_ct,LENGTH] -= offset_length_tail_idx_ops[op_ct:next_op_ct,OFFSET] cls.sparse_usage += offset_length_tail_idx_ops[op_ct:next_op_ct,LENGTH].sum() op_ct = next_op_ct min_hole = max(next_hole, min_hole) next_op_ct = op_ct + offset_length_tail_idx_ops ... here's the code it was likely ported from: length = aligned_tail - aligned_offset next_data = self._next_sparse(next_hole, os.SEEK_DATA) while next_data < tail: assert next_data - next_hole <= length length = next_data - next_hole self.mmap[next_hole:next_data] = super().read(next_hole, length, progress=progress) cls.sparse_usage += length next_hole = self._next_sparse(next_data, os.SEEK_HOLE) next_data = self._next_sparse(next_hole, os.SEEK_DATA) if next_hole < tail: length = aligned_tail - next_hole self.mmap[next_hole:aligned_tail] = super().read(next_hole, length, progress=progress) cls.sparse_usage += length