Uses `bisect` module instead of rolling my own.

Signed-off-by: Xiaomao Chen <xiaomao5@live.com>