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

Skip to content

Commit c6d210c

Browse files
committed
Get rid of last vestiges of BINARY_DIVIDE.
1 parent e4993c7 commit c6d210c

6 files changed

Lines changed: 3 additions & 29 deletions

File tree

Doc/lib/libdis.tex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ \subsection{Python Byte Code Instructions}
189189
Implements \code{TOS = TOS1 * TOS}.
190190
\end{opcodedesc}
191191

192-
\begin{opcodedesc}{BINARY_DIVIDE}{}
193-
Implements \code{TOS = TOS1 / TOS} when
194-
\code{from __future__ import division} is not in effect.
195-
\end{opcodedesc}
196-
197192
\begin{opcodedesc}{BINARY_FLOOR_DIVIDE}{}
198193
Implements \code{TOS = TOS1 // TOS}.
199194
\end{opcodedesc}

Include/opcode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern "C" {
2626
#define BINARY_POWER 19
2727

2828
#define BINARY_MULTIPLY 20
29-
#define BINARY_DIVIDE 21
29+
3030
#define BINARY_MODULO 22
3131
#define BINARY_ADD 23
3232
#define BINARY_SUBTRACT 24

Lib/compiler/pycodegen.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,12 @@ def __init__(self):
206206
self.setups = misc.Stack()
207207
self.last_lineno = None
208208
self._setupGraphDelegation()
209-
self._div_op = "BINARY_DIVIDE"
210209

211210
# XXX set flags based on future features
212211
futures = self.get_module().futures
213212
for feature in futures:
214213
if feature == "division":
215214
self.graph.setFlag(CO_FUTURE_DIVISION)
216-
self._div_op = "BINARY_TRUE_DIVIDE"
217215
elif feature == "absolute_import":
218216
self.graph.setFlag(CO_FUTURE_ABSIMPORT)
219217
elif feature == "with_statement":
@@ -1177,7 +1175,7 @@ def visitMul(self, node):
11771175
return self.binaryOp(node, 'BINARY_MULTIPLY')
11781176

11791177
def visitDiv(self, node):
1180-
return self.binaryOp(node, self._div_op)
1178+
return self.binaryOp(node, 'BINARY_TRUE_DIVIDE')
11811179

11821180
def visitFloorDiv(self, node):
11831181
return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')

Lib/opcode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def jabs_op(name, op):
6161
def_op('LIST_APPEND', 18)
6262
def_op('BINARY_POWER', 19)
6363
def_op('BINARY_MULTIPLY', 20)
64-
def_op('BINARY_DIVIDE', 21)
64+
6565
def_op('BINARY_MODULO', 22)
6666
def_op('BINARY_ADD', 23)
6767
def_op('BINARY_SUBTRACT', 24)

Python/ceval.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,19 +1073,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throw)
10731073
if (x != NULL) continue;
10741074
break;
10751075

1076-
case BINARY_DIVIDE:
1077-
if (!_Py_QnewFlag) {
1078-
w = POP();
1079-
v = TOP();
1080-
x = PyNumber_Divide(v, w);
1081-
Py_DECREF(v);
1082-
Py_DECREF(w);
1083-
SET_TOP(x);
1084-
if (x != NULL) continue;
1085-
break;
1086-
}
1087-
/* -Qnew is in effect: fall through to
1088-
BINARY_TRUE_DIVIDE */
10891076
case BINARY_TRUE_DIVIDE:
10901077
w = POP();
10911078
v = TOP();

Python/compile.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,6 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
479479
case BINARY_MULTIPLY:
480480
newconst = PyNumber_Multiply(v, w);
481481
break;
482-
case BINARY_DIVIDE:
483-
/* Cannot fold this operation statically since
484-
the result can depend on the run-time presence
485-
of the -Qnew flag */
486-
return 0;
487482
case BINARY_TRUE_DIVIDE:
488483
newconst = PyNumber_TrueDivide(v, w);
489484
break;
@@ -1302,7 +1297,6 @@ opcode_stack_effect(int opcode, int oparg)
13021297

13031298
case BINARY_POWER:
13041299
case BINARY_MULTIPLY:
1305-
case BINARY_DIVIDE:
13061300
case BINARY_MODULO:
13071301
case BINARY_ADD:
13081302
case BINARY_SUBTRACT:

0 commit comments

Comments
 (0)