def bsearch(arr, t):
    """
    arr: Iterable, sorted.
    t: target.
    return: i or None (index of target)
    """
    if not arr or t is None:
        return None
    
    low = 0
    high = len(arr) - 1
    
    while low <= high:
        mid = low + ((high - low) >> 1) # or just // 2
        if arr[mid] < t:
            low = mid + 1
        elif arr[mid] > t:
            high = mid - 1
        else:
            return mid
    
    return None