def rawbigcount(filename):
    f = open(filename, 'rb')
bufgen = takewhile(lambda x: x, (f.raw.read(1024 * 1024) for _ in repeat(None))
    )
return sum(buf.count('\n') for buf in bufgen if buf)
how to count the total number of lines in a text file using python