[Python-checkins] python/dist/src/Objects listobject.c,2.190,2.191
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Thu Mar 11 02:34:21 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17157
Modified Files:
listobject.c
Log Message:
list_inplace_concat() is now expressed in terms of list_extend() which
avoids creating an intermediate tuple for iterable arguments other than
lists or tuples.
In other words, a+=b no longer requires extra memory when b is not a
list or tuple. The list and tuple cases are unchanged.
Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.190
retrieving revision 2.191
diff -C2 -d -r2.190 -r2.191
*** listobject.c 10 Mar 2004 11:44:04 -0000 2.190
--- listobject.c 11 Mar 2004 07:34:19 -0000 2.191
***************
*** 709,726 ****
static PyObject *
- list_inplace_concat(PyListObject *self, PyObject *other)
- {
- other = PySequence_Fast(other, "argument to += must be iterable");
- if (!other)
- return NULL;
-
- if (listextend_internal(self, other) < 0)
- return NULL;
-
- Py_INCREF(self);
- return (PyObject *)self;
- }
-
- static PyObject *
listextend(PyListObject *self, PyObject *b)
{
--- 709,712 ----
***************
*** 792,795 ****
--- 778,794 ----
static PyObject *
+ list_inplace_concat(PyListObject *self, PyObject *other)
+ {
+ PyObject *result;
+
+ result = listextend(self, other);
+ if (result == NULL)
+ return result;
+ Py_DECREF(result);
+ Py_INCREF(self);
+ return (PyObject *)self;
+ }
+
+ static PyObject *
listpop(PyListObject *self, PyObject *args)
{
More information about the Python-checkins
mailing list