[Python-checkins] python/dist/src/Objects listobject.c,2.178,2.179

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Fri Feb 13 13:36:36 EST 2004


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

Modified Files:
	listobject.c 
Log Message:
Optimize list.pop() for the common special case of popping off the end.
More than doubles its speed.



Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.178
retrieving revision 2.179
diff -C2 -d -r2.178 -r2.179
*** listobject.c	13 Feb 2004 11:36:39 -0000	2.178
--- listobject.c	13 Feb 2004 18:36:31 -0000	2.179
***************
*** 740,743 ****
--- 740,748 ----
  	}
  	v = self->ob_item[i];
+ 	if (i == self->ob_size - 1) {
+ 		if (list_resize(self, self->ob_size - 1) == -1)
+ 			return NULL;
+ 		return v;
+ 	}
  	Py_INCREF(v);
  	if (list_ass_slice(self, i, i+1, (PyObject *)NULL) != 0) {




More information about the Python-checkins mailing list