Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1018fad

Browse files
committed
Issue #28792: Remove aliases from _bisect
Remove aliases from the C module. Always implement bisect() and insort() aliases in bisect.py Remove also the "# backward compatibility" command, there is no plan to deprecate nor remove these aliases. When keys are equal, it makes sense to use bisect.bisect() and bisect.insort().
1 parent ed6de73 commit 1018fad

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

Lib/bisect.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ def insort_right(a, x, lo=0, hi=None):
1919
else: lo = mid+1
2020
a.insert(lo, x)
2121

22-
insort = insort_right # backward compatibility
23-
2422
def bisect_right(a, x, lo=0, hi=None):
2523
"""Return the index where to insert item x in list a, assuming a is sorted.
2624
@@ -42,8 +40,6 @@ def bisect_right(a, x, lo=0, hi=None):
4240
else: lo = mid+1
4341
return lo
4442

45-
bisect = bisect_right # backward compatibility
46-
4743
def insort_left(a, x, lo=0, hi=None):
4844
"""Insert item x in list a, and keep it sorted assuming a is sorted.
4945
@@ -90,3 +86,7 @@ def bisect_left(a, x, lo=0, hi=None):
9086
from _bisect import *
9187
except ImportError:
9288
pass
89+
90+
# Create aliases
91+
bisect = bisect_right
92+
insort = insort_right

Modules/_bisectmodule.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,11 @@ If x is already in a, insert it to the left of the leftmost x.\n\
216216
Optional args lo (default 0) and hi (default len(a)) bound the\n\
217217
slice of a to be searched.\n");
218218

219-
PyDoc_STRVAR(bisect_doc, "Alias for bisect_right().\n");
220-
PyDoc_STRVAR(insort_doc, "Alias for insort_right().\n");
221-
222219
static PyMethodDef bisect_methods[] = {
223220
{"bisect_right", (PyCFunction)bisect_right,
224221
METH_VARARGS|METH_KEYWORDS, bisect_right_doc},
225-
{"bisect", (PyCFunction)bisect_right,
226-
METH_VARARGS|METH_KEYWORDS, bisect_doc},
227222
{"insort_right", (PyCFunction)insort_right,
228223
METH_VARARGS|METH_KEYWORDS, insort_right_doc},
229-
{"insort", (PyCFunction)insort_right,
230-
METH_VARARGS|METH_KEYWORDS, insort_doc},
231224
{"bisect_left", (PyCFunction)bisect_left,
232225
METH_VARARGS|METH_KEYWORDS, bisect_left_doc},
233226
{"insort_left", (PyCFunction)insort_left,

0 commit comments

Comments
 (0)