@@ -24,6 +24,8 @@ method to determine whether a value has been found. Instead, the
2424functions only call the :meth: `__lt__ ` method and will return an insertion
2525point between values in an array.
2626
27+ .. _bisect functions :
28+
2729The following functions are provided:
2830
2931
@@ -55,7 +57,7 @@ The following functions are provided:
5557.. function :: bisect_right(a, x, lo=0, hi=len(a), *, key=None)
5658 bisect(a, x, lo=0, hi=len(a), *, key=None)
5759
58- Similar to :func: `bisect_left `, but returns an insertion point which comes
60+ Similar to :py: func: `~bisect. bisect_left `, but returns an insertion point which comes
5961 after (to the right of) any existing entries of *x * in *a *.
6062
6163 The returned insertion point *ip * partitions the array *a * into two slices
@@ -70,7 +72,7 @@ The following functions are provided:
7072
7173 Insert *x * in *a * in sorted order.
7274
73- This function first runs :func: `bisect_left ` to locate an insertion point.
75+ This function first runs :py: func: `~bisect. bisect_left ` to locate an insertion point.
7476 Next, it runs the :meth: `insert ` method on *a * to insert *x * at the
7577 appropriate position to maintain sort order.
7678
@@ -87,10 +89,10 @@ The following functions are provided:
8789.. function :: insort_right(a, x, lo=0, hi=len(a), *, key=None)
8890 insort(a, x, lo=0, hi=len(a), *, key=None)
8991
90- Similar to :func: `insort_left `, but inserting *x * in *a * after any existing
92+ Similar to :py: func: `~bisect. insort_left `, but inserting *x * in *a * after any existing
9193 entries of *x *.
9294
93- This function first runs :func: `bisect_right ` to locate an insertion point.
95+ This function first runs :py: func: `~bisect. bisect_right ` to locate an insertion point.
9496 Next, it runs the :meth: `insert ` method on *a * to insert *x * at the
9597 appropriate position to maintain sort order.
9698
@@ -120,7 +122,7 @@ thoughts in mind:
120122 they are used. Consequently, if the search functions are used in a loop,
121123 the key function may be called again and again on the same array elements.
122124 If the key function isn't fast, consider wrapping it with
123- :func: `functools.cache ` to avoid duplicate computations. Alternatively,
125+ :py: func: `functools.cache ` to avoid duplicate computations. Alternatively,
124126 consider searching an array of precomputed keys to locate the insertion
125127 point (as shown in the examples section below).
126128
@@ -140,7 +142,7 @@ thoughts in mind:
140142Searching Sorted Lists
141143----------------------
142144
143- The above :func: `bisect ` functions are useful for finding insertion points but
145+ The above `bisect functions `_ are useful for finding insertion points but
144146can be tricky or awkward to use for common searching tasks. The following five
145147functions show how to transform them into the standard lookups for sorted
146148lists::
@@ -186,8 +188,8 @@ Examples
186188
187189.. _bisect-example :
188190
189- The :func: `bisect ` function can be useful for numeric table lookups. This
190- example uses :func: `bisect ` to look up a letter grade for an exam score (say)
191+ The :py: func: `~bisect. bisect ` function can be useful for numeric table lookups. This
192+ example uses :py: func: `~bisect. bisect ` to look up a letter grade for an exam score (say)
191193based on a set of ordered numeric breakpoints: 90 and up is an 'A', 80 to 89 is
192194a 'B', and so on::
193195
@@ -198,8 +200,8 @@ a 'B', and so on::
198200 >>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
199201 ['F', 'A', 'C', 'C', 'B', 'A', 'A']
200202
201- The :func: `bisect ` and :func: `insort ` functions also work with lists of
202- tuples. The *key * argument can serve to extract the field used for ordering
203+ The :py: func: `~ bisect.bisect ` and :py: func: `~bisect. insort ` functions also work with
204+ lists of tuples. The *key * argument can serve to extract the field used for ordering
203205records in a table::
204206
205207 >>> from collections import namedtuple
0 commit comments