[Python-checkins] python/dist/src/Python bltinmodule.c,2.306,2.307
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Jan 4 06:00:10 EST 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv5064/Python
Modified Files:
bltinmodule.c
Log Message:
Apply pre-sizing optimization to a broader class of objects.
Formerly, the length was only fetched from sequence objects.
Now, any object that reports its length can benefit from pre-sizing.
Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.306
retrieving revision 2.307
diff -C2 -d -r2.306 -r2.307
*** bltinmodule.c 4 Jan 2004 08:54:44 -0000 2.306
--- bltinmodule.c 4 Jan 2004 11:00:07 -0000 2.307
***************
*** 154,166 ****
/* Guess a result list size. */
! len = -1; /* unknown */
! if (PySequence_Check(seq) &&
! seq->ob_type->tp_as_sequence->sq_length) {
! len = PySequence_Size(seq);
! if (len < 0)
! PyErr_Clear();
}
- if (len < 0)
- len = 8; /* arbitrary */
/* Pre-allocate argument list tuple. */
--- 154,162 ----
/* Guess a result list size. */
! len = PyObject_Size(seq);
! if (len < 0) {
! PyErr_Clear();
! len = 8; /* arbitrary */
}
/* Pre-allocate argument list tuple. */
More information about the Python-checkins
mailing list