Skip to content

Commit

Permalink
Issue python#28792: Remove aliases from _bisect
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
vstinner committed Nov 24, 2016
1 parent ed6de73 commit 1018fad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 4 additions & 4 deletions Lib/bisect.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ def insort_right(a, x, lo=0, hi=None):
else: lo = mid+1
a.insert(lo, x)

insort = insort_right # backward compatibility

def bisect_right(a, x, lo=0, hi=None):
"""Return the index where to insert item x in list a, assuming a is sorted.
Expand All @@ -42,8 +40,6 @@ def bisect_right(a, x, lo=0, hi=None):
else: lo = mid+1
return lo

bisect = bisect_right # backward compatibility

def insort_left(a, x, lo=0, hi=None):
"""Insert item x in list a, and keep it sorted assuming a is sorted.
Expand Down Expand Up @@ -90,3 +86,7 @@ def bisect_left(a, x, lo=0, hi=None):
from _bisect import *
except ImportError:
pass

# Create aliases
bisect = bisect_right
insort = insort_right
7 changes: 0 additions & 7 deletions Modules/_bisectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,11 @@ If x is already in a, insert it to the left of the leftmost x.\n\
Optional args lo (default 0) and hi (default len(a)) bound the\n\
slice of a to be searched.\n");

PyDoc_STRVAR(bisect_doc, "Alias for bisect_right().\n");
PyDoc_STRVAR(insort_doc, "Alias for insort_right().\n");

static PyMethodDef bisect_methods[] = {
{"bisect_right", (PyCFunction)bisect_right,
METH_VARARGS|METH_KEYWORDS, bisect_right_doc},
{"bisect", (PyCFunction)bisect_right,
METH_VARARGS|METH_KEYWORDS, bisect_doc},
{"insort_right", (PyCFunction)insort_right,
METH_VARARGS|METH_KEYWORDS, insort_right_doc},
{"insort", (PyCFunction)insort_right,
METH_VARARGS|METH_KEYWORDS, insort_doc},
{"bisect_left", (PyCFunction)bisect_left,
METH_VARARGS|METH_KEYWORDS, bisect_left_doc},
{"insort_left", (PyCFunction)insort_left,
Expand Down

0 comments on commit 1018fad

Please sign in to comment.