@@ -27,7 +27,20 @@ def binary_search_by_index(sequence, value,
2727 '''
2828 Do a binary search, returning answer as index number.
2929
30- Similiar to binary_search (refer to its documentation for more info). The
30+ For all rounding options, a return value of None is returned if no matching
31+ item is found. (In the case of `rounding=BOTH`, either of the items in the
32+ tuple may be `None`)
33+
34+ You may optionally pass a key function as `function`, so instead of the
35+ objects in `sequence` being compared, their outputs from `function` will be
36+ compared. If you do pass in a function, it's assumed that it's strictly
37+ rising.
38+
39+ Note: This function uses `None` to express its inability to find any
40+ matches; therefore, you better not use it on sequences in which None is a
41+ possible item.
42+
43+ Similiar to `binary_search` (refer to its documentation for more info). The
3144 difference is that instead of returning a result in terms of sequence
3245 items, it returns the indexes of these items in the sequence.
3346
@@ -45,8 +58,10 @@ def _binary_search_both(sequence, value,
4558 '''
4659 Do a binary search through a sequence with the `BOTH` rounding.
4760
48- It is assumed that `function` is a strictly monotonic rising function on
49- `sequence`.
61+ You may optionally pass a key function as `function`, so instead of the
62+ objects in `sequence` being compared, their outputs from `function` will be
63+ compared. If you do pass in a function, it's assumed that it's strictly
64+ rising.
5065
5166 Note: This function uses `None` to express its inability to find any
5267 matches; therefore, you better not use it on sequences in which `None` is a
@@ -106,13 +121,15 @@ def binary_search(sequence, value, function=misc_tools.identity_function,
106121 '''
107122 Do a binary search through a sequence.
108123
109- It is assumed that `function` is a strictly monotonic rising function on
110- `sequence`.
111-
112124 For all rounding options, a return value of None is returned if no matching
113125 item is found. (In the case of `rounding=BOTH`, either of the items in the
114126 tuple may be `None`)
115127
128+ You may optionally pass a key function as `function`, so instead of the
129+ objects in `sequence` being compared, their outputs from `function` will be
130+ compared. If you do pass in a function, it's assumed that it's strictly
131+ rising.
132+
116133 Note: This function uses `None` to express its inability to find any
117134 matches; therefore, you better not use it on sequences in which None is a
118135 possible item.
0 commit comments