def lines_in_file(path):
    """
    Returns the number of lines in a file
    :param str path:
    :return: the number of lines
    :rtype: int
    """
    with open(path) as f:
        position = f.tell()
        f.seek(0, 2)  # seek to end
        num_rows = f.tell()
        f.seek(position)  # back

    return num_rows