diff options
author | Guido van Rossum <guido@python.org> | 1998-07-10 18:03:50 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-07-10 18:03:50 (GMT) |
commit | 5dba9e8aef544c0f10bda0ecbd965ac08d019f27 (patch) | |
tree | 3c8346d86b20b5e7b4cc62c965df9741635d7377 /Objects | |
parent | fa4ac71dd6602347d80e4cdb71f3867fb63d3578 (diff) | |
download | cpython-5dba9e8aef544c0f10bda0ecbd965ac08d019f27.zip cpython-5dba9e8aef544c0f10bda0ecbd965ac08d019f27.tar.gz cpython-5dba9e8aef544c0f10bda0ecbd965ac08d019f27.tar.bz2 |
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.)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index a94a136..cfa4cc8 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; |