I have a large file containing 10_000_000 lines. I would like to get for example line number 5_000_000. I constructed this function in python:
def read_n_line(file: str, n: int) -> str:
    """Function returns n-th line of file"""
    with open(file) as f:
        content = f.readlines()
    return content[n]
but it is terribly slow on such big files. Is there a better way how to do this?
In bash I can do something like sed -n '5000000p' < my_file which is fast enough.
 
    