def find_line(view, start=0, end=-1, target=0):

    # Don't bother if sought line is beyond buffer boundaries.
    if  target < 0 or target > view.rowcol(view.size())[0] + 1:
        return -1

    if end == -1:
        end = view.size()

    lo, hi = start, end
    while lo <= hi:
        middle = lo + (hi - lo) / 2
        if get_line_nr(view, middle) < target:
            lo = find_eol(view, middle) + 1
        elif get_line_nr(view, middle) > target:
            hi = find_bol(view, middle) - 1
        else:
            return view.full_line(middle)
    return -1
Do binary search to find :target: line number.
dataset/ETHPy150Open guillermooo/Vintageous/ex/ex_location.py/find_line