def count_lines_in_file(file_path: str, buffer_size: int = 1024 * 1024) -> int:
    """Count the number of lines in the given file.

    :param file_path: path to the file
    :param buffer_size: size of temporary buffer during reading the file
    :return: number of lines
    """
    n_lines = 0
    with open(file_path, "rb") as file:
        file_reader = file.read
        buffer = file_reader(buffer_size)
        while buffer:
            n_lines += buffer.count(b"\n")
            buffer = file_reader(buffer_size)
    return n_lines