]> granicus.if.org Git - python/commitdiff
Add special case to PySequence_List() so that list() of a list is
authorGuido van Rossum <guido@python.org>
Fri, 10 Jul 1998 18:03:50 +0000 (18:03 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 10 Jul 1998 18:03:50 +0000 (18:03 +0000)
faster (using PyList_GetSlice()).  Also added a test for a NULL
argument, as with PySequence_Tuple().  (Hmm...  Better names for these
two would be PyList_FromSequence() and PyTuple_FromSequence().  Oh well.)

Objects/abstract.c

index a94a1368c9d54d7c9b95686de6b6446983007caf..cfa4cc839c8c7c7570b829502d338138b5e7b5d1 100644 (file)
@@ -1055,6 +1055,12 @@ PySequence_List(v)
 {
        PySequenceMethods *m;
 
+       if (v == NULL)
+               return null_error();
+
+       if (PyList_Check(v))
+               return PyList_GetSlice(v, 0, PyList_GET_SIZE(v));
+
        m = v->ob_type->tp_as_sequence;
        if (m && m->sq_item) {
                int i;