def get_gaps_and_overlaps2(self, tier1, tier2, maxlen=-<NUM_LIT:1>):
ad = sorted(((a, i+<NUM_LIT:1>) for i, t in enumerate([tier1, tier2]) for a in<EOL>self.get_annotation_data_for_tier(t)), reverse=True)<EOL>if ad:<EOL><INDENT>last = (lambda x: (x[<NUM_LIT:0>][<NUM_LIT:0>], x[<NUM_LIT:0>][<NUM_LIT:1>], x[<NUM_LIT:1>]))(ad.pop())<EOL>def thr(x, y):<EOL><INDENT>return maxlen == -<NUM_LIT:1> or abs(x-y) < maxlen<EOL><DEDENT>while ad:<EOL><INDENT>(begin, end, _), current = ad.pop()<EOL>if last[<NUM_LIT:2>] == current and thr(begin, last[<NUM_LIT:1>]):<EOL><INDENT>yield (last[<NUM_LIT:1>], begin, '<STR_LIT>'.format(current))<EOL><DEDENT>elif last[<NUM_LIT:0>] < begin and last[<NUM_LIT:1>] > end:<EOL><INDENT>yield (begin, end, '<STR_LIT>'.format(last[<NUM_LIT:2>], current))<EOL>continue<EOL><DEDENT>elif last[<NUM_LIT:1>] > begin:<EOL><INDENT>yield (begin, last[<NUM_LIT:1>], '<STR_LIT>'.format(last[<NUM_LIT:2>], current))<EOL><DEDENT>elif last[<NUM_LIT:1>] < begin and thr(begin, last[<NUM_LIT:1>]):<EOL><INDENT>yield (last[<NUM_LIT:1>], begin, '<STR_LIT>'.format(last[<NUM_LIT:2>], current))<EOL><DEDENT>last = (begin, end, current)<EOL><DEDENT><DEDENT>
Faster variant of :func:`get_gaps_and_overlaps`. Faster in this case
        means almost 100 times faster...

        :param str tier1: Name of the first tier.
        :param str tier2: Name of the second tier.
        :param int maxlen: Maximum length of gaps (skip longer ones), if ``-1``
                           no maximum will be used.
        :yields: Tuples of the form ``[(start, end, type)]``.
        :raises KeyError: If a tier is non existent.