[Python-checkins] python/dist/src/Python ceval.c,2.380,2.381
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Fri Mar 12 03:42:01 EST 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25035
Modified Files:
ceval.c
Log Message:
Speedup for-loops by inlining PyIter_Next(). Saves duplicate tests
and a function call resulting in a 15% reduction of total loop overhead
(as measured by timeit.Timer('pass')).
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.380
retrieving revision 2.381
diff -C2 -d -r2.380 -r2.381
*** ceval.c 8 Mar 2004 23:25:30 -0000 2.380
--- ceval.c 12 Mar 2004 08:41:36 -0000 2.381
***************
*** 2092,2096 ****
/* before: [iter]; after: [iter, iter()] *or* [] */
v = TOP();
! x = PyIter_Next(v);
if (x != NULL) {
PUSH(x);
--- 2092,2096 ----
/* before: [iter]; after: [iter, iter()] *or* [] */
v = TOP();
! x = (*v->ob_type->tp_iternext)(v);
if (x != NULL) {
PUSH(x);
***************
*** 2099,2110 ****
continue;
}
! if (!PyErr_Occurred()) {
! /* iterator ended normally */
! x = v = POP();
! Py_DECREF(v);
! JUMPBY(oparg);
! continue;
}
! break;
case SETUP_LOOP:
--- 2099,2112 ----
continue;
}
! if (PyErr_Occurred()) {
! if (!PyErr_ExceptionMatches(PyExc_StopIteration))
! break;
! PyErr_Clear();
}
! /* iterator ended normally */
! x = v = POP();
! Py_DECREF(v);
! JUMPBY(oparg);
! continue;
case SETUP_LOOP:
More information about the Python-checkins
mailing list