You can use the line_count() function from the itertools module to get the line count of a large file cheaply in Python.