summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-30 16:06:23 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-30 16:06:23 (GMT)
commit46add98758415f6180532326571d73f22966c34e (patch)
treeed5fd8f7babfbfea5e8089ef8b00be286802d9bf /Python/ceval.c
parent13228a6f099cbf4855fa0dc0ee921f174bc967ff (diff)
downloadcpython-46add98758415f6180532326571d73f22966c34e.zip
cpython-46add98758415f6180532326571d73f22966c34e.tar.gz
cpython-46add98758415f6180532326571d73f22966c34e.tar.bz2
Do the int inlining only if the type is really an int, not whenever
PyInt_Check() succeeds. That returns true for subtypes of int, which may override __add__ or __sub__.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index cb95aaa..6eebf94 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -548,6 +548,9 @@ eval_frame(PyFrameObject *f)
#define POP() BASIC_POP()
#endif
+/* Strict int check macros */
+#define ISSTRICTINT(v) ((v)->ob_type == &PyInt_Type)
+
/* Local variable macros */
#define GETLOCAL(i) (fastlocals[i])
@@ -909,7 +912,7 @@ eval_frame(PyFrameObject *f)
case BINARY_ADD:
w = POP();
v = POP();
- if (PyInt_Check(v) && PyInt_Check(w)) {
+ if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
/* INLINE: int + int */
register long a, b, i;
a = PyInt_AS_LONG(v);
@@ -932,7 +935,7 @@ eval_frame(PyFrameObject *f)
case BINARY_SUBTRACT:
w = POP();
v = POP();
- if (PyInt_Check(v) && PyInt_Check(w)) {
+ if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
/* INLINE: int - int */
register long a, b, i;
a = PyInt_AS_LONG(v);
@@ -955,7 +958,7 @@ eval_frame(PyFrameObject *f)
case BINARY_SUBSCR:
w = POP();
v = POP();
- if (v->ob_type == &PyList_Type && PyInt_Check(w)) {
+ if (v->ob_type == &PyList_Type && ISSTRICTINT(w)) {
/* INLINE: list[int] */
long i = PyInt_AsLong(w);
if (i < 0)
@@ -1092,7 +1095,7 @@ eval_frame(PyFrameObject *f)
case INPLACE_ADD:
w = POP();
v = POP();
- if (PyInt_Check(v) && PyInt_Check(w)) {
+ if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
/* INLINE: int + int */
register long a, b, i;
a = PyInt_AS_LONG(v);
@@ -1115,7 +1118,7 @@ eval_frame(PyFrameObject *f)
case INPLACE_SUBTRACT:
w = POP();
v = POP();
- if (PyInt_Check(v) && PyInt_Check(w)) {
+ if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
/* INLINE: int - int */
register long a, b, i;
a = PyInt_AS_LONG(v);
@@ -1718,7 +1721,7 @@ eval_frame(PyFrameObject *f)
case COMPARE_OP:
w = POP();
v = POP();
- if (PyInt_Check(v) && PyInt_Check(w)) {
+ if (ISSTRICTINT(v) && ISSTRICTINT(w)) {
/* INLINE: cmp(int, int) */
register long a, b;
register int res;