Skip to content

Commit ebd3db8

Browse files
rhettingerwarsaw
authored andcommitted
pythonGH-102833: Mention the key function in the docstrings (pythonGH-103009)
1 parent e61e12f commit ebd3db8

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

Lib/bisect.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def insort_right(a, x, lo=0, hi=None, *, key=None):
88
99
Optional args lo (default 0) and hi (default len(a)) bound the
1010
slice of a to be searched.
11+
12+
A custom key function can be supplied to customize the sort order.
1113
"""
1214
if key is None:
1315
lo = bisect_right(a, x, lo, hi)
@@ -25,6 +27,8 @@ def bisect_right(a, x, lo=0, hi=None, *, key=None):
2527
2628
Optional args lo (default 0) and hi (default len(a)) bound the
2729
slice of a to be searched.
30+
31+
A custom key function can be supplied to customize the sort order.
2832
"""
2933

3034
if lo < 0:
@@ -57,6 +61,8 @@ def insort_left(a, x, lo=0, hi=None, *, key=None):
5761
5862
Optional args lo (default 0) and hi (default len(a)) bound the
5963
slice of a to be searched.
64+
65+
A custom key function can be supplied to customize the sort order.
6066
"""
6167

6268
if key is None:
@@ -74,6 +80,8 @@ def bisect_left(a, x, lo=0, hi=None, *, key=None):
7480
7581
Optional args lo (default 0) and hi (default len(a)) bound the
7682
slice of a to be searched.
83+
84+
A custom key function can be supplied to customize the sort order.
7785
"""
7886

7987
if lo < 0:

Modules/_bisectmodule.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,14 @@ insert just after the rightmost x already there.
162162
163163
Optional args lo (default 0) and hi (default len(a)) bound the
164164
slice of a to be searched.
165+
166+
A custom key function can be supplied to customize the sort order.
165167
[clinic start generated code]*/
166168

167169
static Py_ssize_t
168170
_bisect_bisect_right_impl(PyObject *module, PyObject *a, PyObject *x,
169171
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
170-
/*[clinic end generated code: output=3a4bc09cc7c8a73d input=40fcc5afa06ae593]*/
172+
/*[clinic end generated code: output=3a4bc09cc7c8a73d input=43071869772dd53a]*/
171173
{
172174
return internal_bisect_right(a, x, lo, hi, key);
173175
}
@@ -188,12 +190,14 @@ If x is already in a, insert it to the right of the rightmost x.
188190
189191
Optional args lo (default 0) and hi (default len(a)) bound the
190192
slice of a to be searched.
193+
194+
A custom key function can be supplied to customize the sort order.
191195
[clinic start generated code]*/
192196

193197
static PyObject *
194198
_bisect_insort_right_impl(PyObject *module, PyObject *a, PyObject *x,
195199
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
196-
/*[clinic end generated code: output=ac3bf26d07aedda2 input=44e1708e26b7b802]*/
200+
/*[clinic end generated code: output=ac3bf26d07aedda2 input=f60777d2b6ddb239]*/
197201
{
198202
PyObject *result, *key_x;
199203
Py_ssize_t index;
@@ -343,12 +347,14 @@ insert just before the leftmost x already there.
343347
344348
Optional args lo (default 0) and hi (default len(a)) bound the
345349
slice of a to be searched.
350+
351+
A custom key function can be supplied to customize the sort order.
346352
[clinic start generated code]*/
347353

348354
static Py_ssize_t
349355
_bisect_bisect_left_impl(PyObject *module, PyObject *a, PyObject *x,
350356
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
351-
/*[clinic end generated code: output=70749d6e5cae9284 input=90dd35b50ceb05e3]*/
357+
/*[clinic end generated code: output=70749d6e5cae9284 input=f29c4fe7f9b797c7]*/
352358
{
353359
return internal_bisect_left(a, x, lo, hi, key);
354360
}
@@ -370,12 +376,14 @@ If x is already in a, insert it to the left of the leftmost x.
370376
371377
Optional args lo (default 0) and hi (default len(a)) bound the
372378
slice of a to be searched.
379+
380+
A custom key function can be supplied to customize the sort order.
373381
[clinic start generated code]*/
374382

375383
static PyObject *
376384
_bisect_insort_left_impl(PyObject *module, PyObject *a, PyObject *x,
377385
Py_ssize_t lo, Py_ssize_t hi, PyObject *key)
378-
/*[clinic end generated code: output=b1d33e5e7ffff11e input=3ab65d8784f585b1]*/
386+
/*[clinic end generated code: output=b1d33e5e7ffff11e input=0a700a82edbd472c]*/
379387
{
380388
PyObject *result, *key_x;
381389
Py_ssize_t index;

Modules/clinic/_bisectmodule.c.h

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)