diff options
author | 2019-02-25 21:59:12 +0500 | |
---|---|---|
committer | 2019-02-25 17:59:12 +0100 | |
commit | 234531b4462b20d668762bd78406fd2ebab129c9 (patch) | |
tree | f0a93cbdf6ebf42055498ea9533891cec0680bcf /Objects/listobject.c | |
parent | Remove empty Dictionaries section from programming FAQ (GH-12026) (diff) | |
download | cpython-234531b4462b20d668762bd78406fd2ebab129c9.tar.gz cpython-234531b4462b20d668762bd78406fd2ebab129c9.tar.bz2 cpython-234531b4462b20d668762bd78406fd2ebab129c9.zip |
bpo-36030: Add _PyTuple_FromArray() function (GH-11954)
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r-- | Objects/listobject.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c index cbd6e81ea47..b6524e8bd7f 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3,6 +3,7 @@ #include "Python.h" #include "pycore_object.h" #include "pycore_pystate.h" +#include "pycore_tupleobject.h" #include "pycore_accu.h" #ifdef STDC_HEADERS @@ -2501,26 +2502,11 @@ PyList_Reverse(PyObject *v) PyObject * PyList_AsTuple(PyObject *v) { - PyObject *w; - PyObject **p, **q; - Py_ssize_t n; if (v == NULL || !PyList_Check(v)) { PyErr_BadInternalCall(); return NULL; } - n = Py_SIZE(v); - w = PyTuple_New(n); - if (w == NULL) - return NULL; - p = ((PyTupleObject *)w)->ob_item; - q = ((PyListObject *)v)->ob_item; - while (--n >= 0) { - Py_INCREF(*q); - *p = *q; - p++; - q++; - } - return w; + return _PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v)); } /*[clinic input] |