From: Guido van Rossum Date: Fri, 10 Jul 1998 18:03:50 +0000 (+0000) Subject: Add special case to PySequence_List() so that list() of a list is X-Git-Tag: v1.5.2a1~311 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5dba9e8aef544c0f10bda0ecbd965ac08d019f27;p=thirdparty%2FPython%2Fcpython.git Add special case to PySequence_List() so that list() of a list is 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.) --- diff --git a/Objects/abstract.c b/Objects/abstract.c index a94a1368c9d5..cfa4cc839c8c 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -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;