[Python-checkins] python/dist/src/Objects tupleobject.c,2.87,2.88

arigo at users.sourceforge.net arigo at users.sourceforge.net
Sun Mar 21 15:27:51 EST 2004


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

Modified Files:
	tupleobject.c 
Log Message:
This is the fastest I could get on Intel GCC.  I kept the memset() in to clear
the newly created tuples, but tuples added in the freelist are now cleared in
tupledealloc already (which is very cheap, because we are already
Py_XDECREF'ing all elements anyway).

Python should have a standard Py_ZAP macro like ZAP in pystate.c.


Index: tupleobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/tupleobject.c,v
retrieving revision 2.87
retrieving revision 2.88
diff -C2 -d -r2.87 -r2.88
*** tupleobject.c	20 Mar 2004 21:35:09 -0000	2.87
--- tupleobject.c	21 Mar 2004 20:27:49 -0000	2.88
***************
*** 69,75 ****
  		if (op == NULL)
  			return NULL;
  	}
- 	for (i=0; i < size; i++)
- 		op->ob_item[i] = NULL;
  #if MAXSAVESIZE > 0
  	if (size == 0) {
--- 69,74 ----
  		if (op == NULL)
  			return NULL;
+ 		memset(op->ob_item, 0, size*sizeof(PyObject*));
  	}
  #if MAXSAVESIZE > 0
  	if (size == 0) {
***************
*** 166,171 ****
  	if (len > 0) {
  		i = len;
- 		while (--i >= 0)
- 			Py_XDECREF(op->ob_item[i]);
  #if MAXSAVESIZE > 0
  		if (len < MAXSAVESIZE &&
--- 165,168 ----
***************
*** 173,176 ****
--- 170,180 ----
  		    op->ob_type == &PyTuple_Type)
  		{
+ 			while (--i >= 0) {
+ 				PyObject* o = op->ob_item[i];
+ 				if (o != NULL) {
+ 					op->ob_item[i] = NULL;
+ 					Py_DECREF(o);
+ 				}
+ 			}
  			op->ob_item[0] = (PyObject *) free_tuples[len];
  			num_free_tuples[len]++;
***************
*** 178,182 ****
--- 182,189 ----
  			goto done; /* return */
  		}
+ 		else
  #endif
+ 			while (--i >= 0)
+ 				Py_XDECREF(op->ob_item[i]);
  	}
  	op->ob_type->tp_free((PyObject *)op);




More information about the Python-checkins mailing list