[Python-checkins] python/dist/src/Objects listobject.c,2.192,2.193
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Thu Mar 11 04:48:20 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9496
Modified Files:
listobject.c
Log Message:
Now that list.extend() is at the root of many list operations, it becomes
worth it to in-line the call to PyIter_Next().
Saves another 15% on most list operations that acceptable a general
iterable argument (such as the list constructor).
Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.192
retrieving revision 2.193
diff -C2 -d -r2.192 -r2.193
*** listobject.c 11 Mar 2004 09:13:12 -0000 2.192
--- listobject.c 11 Mar 2004 09:48:18 -0000 2.193
***************
*** 716,719 ****
--- 716,720 ----
int mn; /* m + n */
int i;
+ PyObject *(*iternext)(PyObject *);
/* Special cases:
***************
*** 733,736 ****
--- 734,738 ----
if (it == NULL)
return NULL;
+ iternext = *it->ob_type->tp_iternext;
/* Guess a result list size. */
***************
*** 748,755 ****
/* Run iterator to exhaustion. */
for (i = m; ; i++) {
! PyObject *item = PyIter_Next(it);
if (item == NULL) {
! if (PyErr_Occurred())
! goto error;
break;
}
--- 750,761 ----
/* Run iterator to exhaustion. */
for (i = m; ; i++) {
! PyObject *item = iternext(it);
if (item == NULL) {
! if (PyErr_Occurred()) {
! if (PyErr_ExceptionMatches(PyExc_StopIteration))
! PyErr_Clear();
! else
! goto error;
! }
break;
}
More information about the Python-checkins
mailing list