summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-02-26 18:11:50 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-02-26 18:11:50 (GMT)
commit21012b82355b9a3ad09208d0fb9e3f08de6b2ad3 (patch)
treeb6b44764d7bafda0d0581d8b653f4ac434a11ba8 /Python/ceval.c
parenta006b8e4684eb9c6add60c8c9cd8299f8f821975 (diff)
downloadcpython-21012b82355b9a3ad09208d0fb9e3f08de6b2ad3.zip
cpython-21012b82355b9a3ad09208d0fb9e3f08de6b2ad3.tar.gz
cpython-21012b82355b9a3ad09208d0fb9e3f08de6b2ad3.tar.bz2
Micro-optimizations.
* List/Tuple checkexact is faster for the common case. * Testing for Py_True and Py_False can be inlined for faster looping.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 9a5d039..5286d25 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1655,7 +1655,7 @@ eval_frame(PyFrameObject *f)
case UNPACK_SEQUENCE:
v = POP();
- if (PyTuple_Check(v)) {
+ if (PyTuple_CheckExact(v)) {
if (PyTuple_Size(v) != oparg) {
PyErr_SetString(PyExc_ValueError,
"unpack tuple of wrong size");
@@ -1669,7 +1669,7 @@ eval_frame(PyFrameObject *f)
}
}
}
- else if (PyList_Check(v)) {
+ else if (PyList_CheckExact(v)) {
if (PyList_Size(v) != oparg) {
PyErr_SetString(PyExc_ValueError,
"unpack list of wrong size");
@@ -1975,7 +1975,14 @@ eval_frame(PyFrameObject *f)
continue;
case JUMP_IF_FALSE:
- err = PyObject_IsTrue(TOP());
+ w = TOP();
+ if (w == Py_True)
+ continue;
+ if (w == Py_False) {
+ JUMPBY(oparg);
+ continue;
+ }
+ err = PyObject_IsTrue(w);
if (err > 0)
err = 0;
else if (err == 0)
@@ -1985,7 +1992,14 @@ eval_frame(PyFrameObject *f)
continue;
case JUMP_IF_TRUE:
- err = PyObject_IsTrue(TOP());
+ w = TOP();
+ if (w == Py_False)
+ continue;
+ if (w == Py_True) {
+ JUMPBY(oparg);
+ continue;
+ }
+ err = PyObject_IsTrue(w);
if (err > 0) {
err = 0;
JUMPBY(oparg);