12 """Represent a list of integers as a sequence of ranges:
13 ((start_0, end_0), (start_1, end_1), ...), such that the original
14 integers are exactly those x such that start_i <= x < end_i for some i.
16 Ranges are encoded as single integers (start << 32 | end), not as tuples.
19 sorted_list = sorted(list_)
23 if i+1 <
len(sorted_list):
24 if sorted_list[i] == sorted_list[i+1]-1:
26 current_range = sorted_list[last_write+1:i+1]