Find the offsets in a byte code which are start of lines in the source.

  Generate pairs (offset, lineno) as described in Python/compile.c.

  Arguments:
    code: code object.

  Yields:
    Address and line number pairs.

def _findlinestarts(code):
  """Find the offsets in a byte code which are start of lines in the source.

  Generate pairs (offset, lineno) as described in Python/compile.c.

  Arguments:
    code: code object.

  Yields:
    Address and line number pairs.
  """
  byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
  line_increments = [ord(c) for c in code.co_lnotab[1::2]]

  lastlineno = None
  lineno = code.co_firstlineno
  addr = 0
  for byte_incr, line_incr in zip(byte_increments, line_increments):
    if byte_incr:
      if lineno != lastlineno:
        yield (addr, lineno)
        lastlineno = lineno
      addr += byte_incr
    lineno += line_incr
  if lineno != lastlineno:
    yield (addr, lineno)