Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5dba9e8

Browse files
committed
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.)
1 parent fa4ac71 commit 5dba9e8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Objects/abstract.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,12 @@ PySequence_List(v)
10551055
{
10561056
PySequenceMethods *m;
10571057

1058+
if (v == NULL)
1059+
return null_error();
1060+
1061+
if (PyList_Check(v))
1062+
return PyList_GetSlice(v, 0, PyList_GET_SIZE(v));
1063+
10581064
m = v->ob_type->tp_as_sequence;
10591065
if (m && m->sq_item) {
10601066
int i;

0 commit comments

Comments
 (0)