[Python-checkins] python/dist/src/Objects listobject.c,2.182,2.183

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Feb 17 06:36:19 EST 2004


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

Modified Files:
	listobject.c 
Log Message:
Double the speed of list.pop() which was spending most of its time parsing
arguments.



Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.182
retrieving revision 2.183
diff -C2 -d -r2.182 -r2.183
*** listobject.c	15 Feb 2004 03:57:00 -0000	2.182
--- listobject.c	17 Feb 2004 11:36:16 -0000	2.183
***************
*** 773,779 ****
  {
  	int i = -1;
! 	PyObject *v;
! 	if (!PyArg_ParseTuple(args, "|i:pop", &i))
  		return NULL;
  	if (self->ob_size == 0) {
  		/* Special-case most common failure cause */
--- 773,788 ----
  {
  	int i = -1;
! 	PyObject *v, *arg = NULL;
! 
! 	if (!PyArg_UnpackTuple(args, "pop", 0, 1, &arg))
  		return NULL;
+ 	if (arg != NULL) {
+ 		if (PyInt_Check(arg))
+ 			i = (int)(PyInt_AS_LONG((PyIntObject*) arg));
+ 		else {
+ 			PyErr_SetString(PyExc_TypeError, "an integer is required");
+ 			return NULL;
+ 		}
+ 	}
  	if (self->ob_size == 0) {
  		/* Special-case most common failure cause */




More information about the Python-checkins mailing list