[Python-checkins] python/dist/src/Modules itertoolsmodule.c, 1.29, 1.30

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Mar 16 23:27:46 EST 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3834

Modified Files:
	itertoolsmodule.c 
Log Message:
Speedup the inner loops for dropwhile(), islice(), ifilter(), and
ifilterfalse().



Index: itertoolsmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/itertoolsmodule.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** itertoolsmodule.c	10 Feb 2004 20:27:40 -0000	1.29
--- itertoolsmodule.c	17 Mar 2004 04:27:44 -0000	1.30
***************
*** 836,843 ****
  	PyObject *it = lz->it;
  	long ok;
  
  	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
  		if (item == NULL)
  			return NULL;
--- 836,845 ----
  	PyObject *it = lz->it;
  	long ok;
+ 	PyObject *(*iternext)(PyObject *);
  
+ 	assert(PyIter_Check(it));
+ 	iternext = *it->ob_type->tp_iternext;
  	for (;;) {
! 		item = iternext(it);
  		if (item == NULL)
  			return NULL;
***************
*** 1171,1178 ****
  	PyObject *it = lz->it;
  	long oldnext;
  
  	while (lz->cnt < lz->next) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
  		if (item == NULL)
  			return NULL;
--- 1173,1182 ----
  	PyObject *it = lz->it;
  	long oldnext;
+ 	PyObject *(*iternext)(PyObject *);
  
+ 	assert(PyIter_Check(it));
+ 	iternext = *it->ob_type->tp_iternext;
  	while (lz->cnt < lz->next) {
! 		item = iternext(it);
  		if (item == NULL)
  			return NULL;
***************
*** 1183,1187 ****
  		return NULL;
  	assert(PyIter_Check(it));
! 	item = (*it->ob_type->tp_iternext)(it);
  	if (item == NULL)
  		return NULL;
--- 1187,1191 ----
  		return NULL;
  	assert(PyIter_Check(it));
! 	item = iternext(it);
  	if (item == NULL)
  		return NULL;
***************
*** 1784,1791 ****
  	PyObject *it = lz->it;
  	long ok;
  
  	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
  		if (item == NULL)
  			return NULL;
--- 1788,1797 ----
  	PyObject *it = lz->it;
  	long ok;
+ 	PyObject *(*iternext)(PyObject *);
  
+ 	assert(PyIter_Check(it));
+ 	iternext = *it->ob_type->tp_iternext;
  	for (;;) {
! 		item = iternext(it);
  		if (item == NULL)
  			return NULL;
***************
*** 1933,1940 ****
  	PyObject *it = lz->it;
  	long ok;
  
  	for (;;) {
! 		assert(PyIter_Check(it));
! 		item = (*it->ob_type->tp_iternext)(it);
  		if (item == NULL)
  			return NULL;
--- 1939,1948 ----
  	PyObject *it = lz->it;
  	long ok;
+ 	PyObject *(*iternext)(PyObject *);
  
+ 	assert(PyIter_Check(it));
+ 	iternext = *it->ob_type->tp_iternext;
  	for (;;) {
! 		item = iternext(it);
  		if (item == NULL)
  			return NULL;




More information about the Python-checkins mailing list