mirror of
https://github.com/python/cpython.git
synced 2024-11-25 19:03:49 +08:00
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.)
This commit is contained in:
parent
fa4ac71dd6
commit
5dba9e8aef
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user