'Find the first index in self.completions where completions[i] is
greater or equal to s, or the last index if there is no such
one.'

def _binary_search(self, s):

    i = 0
    j = len(self.completions)
    while (j > i):
        m = ((i + j) // 2)
        if (self.completions[m] >= s):
            j = m
        else:
            i = (m + 1)
    return min(i, (len(self.completions) - 1))
