def find_in_inventory_index(invt, pid):
    """ Returns the index from inventory item matching pid """

    def binary_search(invt, value):
        low = 0
        high = len(invt)-1
        while low <= high: 
            mid = (low + high)//2
            if invt[mid].pid > value: high = mid-1
            elif invt[mid].pid < value: low = mid+1
            else: return mid
        return -1

    return binary_search(invt, pid)