summaryrefslogtreecommitdiffstats
path: root/Objects/call.c
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2019-02-25 16:59:12 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-02-25 16:59:12 (GMT)
commit234531b4462b20d668762bd78406fd2ebab129c9 (patch)
treef0a93cbdf6ebf42055498ea9533891cec0680bcf /Objects/call.c
parent55e335d7d59be44819c6b672d258e2d5feb1e633 (diff)
downloadcpython-234531b4462b20d668762bd78406fd2ebab129c9.zip
cpython-234531b4462b20d668762bd78406fd2ebab129c9.tar.gz
cpython-234531b4462b20d668762bd78406fd2ebab129c9.tar.bz2
bpo-36030: Add _PyTuple_FromArray() function (GH-11954)
Diffstat (limited to 'Objects/call.c')
-rw-r--r--Objects/call.c30
1 files changed, 2 insertions, 28 deletions
diff --git a/Objects/call.c b/Objects/call.c
index be8e90d..3250f8a 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -1276,20 +1276,7 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...)
_Py_NO_INLINE PyObject *
_PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs)
{
- PyObject *args;
- Py_ssize_t i;
-
- args = PyTuple_New(nargs);
- if (args == NULL) {
- return NULL;
- }
-
- for (i=0; i < nargs; i++) {
- PyObject *item = stack[i];
- Py_INCREF(item);
- PyTuple_SET_ITEM(args, i, item);
- }
- return args;
+ return _PyTuple_FromArray(stack, nargs);
}
@@ -1297,24 +1284,11 @@ PyObject*
_PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs,
Py_ssize_t start, Py_ssize_t end)
{
- PyObject *args;
- Py_ssize_t i;
-
assert(0 <= start);
assert(end <= nargs);
assert(start <= end);
- args = PyTuple_New(end - start);
- if (args == NULL) {
- return NULL;
- }
-
- for (i=start; i < end; i++) {
- PyObject *item = stack[i];
- Py_INCREF(item);
- PyTuple_SET_ITEM(args, i - start, item);
- }
- return args;
+ return _PyTuple_FromArray(stack + start, end - start);
}