def _gaps_from ( intervals ) : sliding_window = zip ( intervals , intervals [ 1 : ] ) gaps = [ b [ 0 ] - a [ 1 ] for a , b in sliding_window ] return gaps
python detect gaps in list
From a list of intervals extract a list of sorted gaps in the form of [ ( g i ) ] where g is the size of the ith gap .
def _gaps_from(intervals):
    """
    From a list of intervals extract
    a list of sorted gaps in the form of [(g,i)]
    where g is the size of the ith gap.
    """
    sliding_window = zip(intervals, intervals[1:])
    gaps = [b[0] - a[1] for a, b in sliding_window]
    return gaps