Given a list of byte ranges that have to be skipped:
skip_ranges = [(1, 3), (5,7)]
and a binary file:
f = open('test', 'rb')
What is the fastest way to return file contents without bytes 1-3 and 5-7 without modifying the original file?
Input (file contents):
012345678
Output:
048
Please note that this question is specifically about (possibly large) binary files, so a generator would be the best.