def findlinestarts(code):
 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))

def findlinestarts ( code ) : 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 ) )
find the offsets in a byte code which are start of lines in the source .