]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36030: Remove _PyStack_AsTuple() and _PyStack_AsTupleSlice() (GH-12032)
authorSergey Fedoseev <fedoseev.sergey@gmail.com>
Mon, 25 Feb 2019 21:37:26 +0000 (02:37 +0500)
committerVictor Stinner <vstinner@redhat.com>
Mon, 25 Feb 2019 21:37:26 +0000 (22:37 +0100)
Include/cpython/abstract.h
Objects/call.c
Python/bltinmodule.c

index 0e002659f6bffe4fbda1b81f9045de95e70e784b..991bea14ebf086e88fe91024627ee3d3b2729cb9 100644 (file)
@@ -12,16 +12,6 @@ extern "C" {
 #  define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
 #endif
 
-PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
-    PyObject *const *stack,
-    Py_ssize_t nargs);
-
-PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
-    PyObject *const *stack,
-    Py_ssize_t nargs,
-    Py_ssize_t start,
-    Py_ssize_t end);
-
 /* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
    format to a Python dictionary ("kwargs" dict).
 
index 3250f8a10dffcd1e21989eaad04a9c5f0b1f18bb..d52e7e26aeba66293384f3112e672f0fffdb37fe 100644 (file)
@@ -114,7 +114,7 @@ _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, Py_ssize_t nar
             return NULL;
         }
 
-        argstuple = _PyStack_AsTuple(args, nargs);
+        argstuple = _PyTuple_FromArray(args, nargs);
         if (argstuple == NULL) {
             return NULL;
         }
@@ -176,7 +176,7 @@ _PyObject_FastCallKeywords(PyObject *callable, PyObject *const *stack, Py_ssize_
             return NULL;
         }
 
-        argstuple = _PyStack_AsTuple(stack, nargs);
+        argstuple = _PyTuple_FromArray(stack, nargs);
         if (argstuple == NULL) {
             return NULL;
         }
@@ -508,7 +508,7 @@ _PyMethodDef_RawFastCallDict(PyMethodDef *method, PyObject *self,
     case METH_VARARGS | METH_KEYWORDS:
     {
         /* Slow-path: create a temporary tuple for positional arguments */
-        PyObject *argstuple = _PyStack_AsTuple(args, nargs);
+        PyObject *argstuple = _PyTuple_FromArray(args, nargs);
         if (argstuple == NULL) {
             goto exit;
         }
@@ -670,7 +670,7 @@ _PyMethodDef_RawFastCallKeywords(PyMethodDef *method, PyObject *self,
            and a temporary dict for keyword arguments */
         PyObject *argtuple;
 
-        argtuple = _PyStack_AsTuple(args, nargs);
+        argtuple = _PyTuple_FromArray(args, nargs);
         if (argtuple == NULL) {
             goto exit;
         }
@@ -1271,27 +1271,6 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...)
 
 /* --- PyStack functions ------------------------------------------ */
 
-/* Issue #29234: Inlining _PyStack_AsTuple() into callers increases their
-   stack consumption, Disable inlining to optimize the stack consumption. */
-_Py_NO_INLINE PyObject *
-_PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs)
-{
-    return _PyTuple_FromArray(stack, nargs);
-}
-
-
-PyObject*
-_PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs,
-                      Py_ssize_t start, Py_ssize_t end)
-{
-    assert(0 <= start);
-    assert(end <= nargs);
-    assert(start <= end);
-
-    return _PyTuple_FromArray(stack + start, end - start);
-}
-
-
 PyObject *
 _PyStack_AsDict(PyObject *const *values, PyObject *kwnames)
 {
index eebdc5ba05317358dbabe4883257346ab8818046..a19b8b8ddc86cefa8c6218d11dcadae8c7971740 100644 (file)
@@ -5,6 +5,7 @@
 #include "ast.h"
 #undef Yield   /* undefine macro conflicting with <winbase.h> */
 #include "pycore_pystate.h"
+#include "pycore_tupleobject.h"
 
 _Py_IDENTIFIER(__builtins__);
 _Py_IDENTIFIER(__dict__);
@@ -121,7 +122,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
                         "__build_class__: name is not a string");
         return NULL;
     }
-    orig_bases = _PyStack_AsTupleSlice(args, nargs, 2, nargs);
+    orig_bases = _PyTuple_FromArray(args + 2, nargs - 2);
     if (orig_bases == NULL)
         return NULL;