Or you can implement a binary search in your type's __contains__ and just use `"foo" in c`
class C:
def __len__(self): ...
def __getitem__(self, i): ...
def __contains__(self, x):
i = bisect.bisect_left(self, x)
return i < len(self) and self[i] == x
At that point it's just syntactic sugar.