mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-45256: Remove the usage of the C stack in Python to Python calls (GH-28488)
Ths commit inlines calls to Python functions in the eval loop and steals all the arguments in the call from the caller for performance.
This commit is contained in:
parent
ec04db74e2
commit
b4903afd4d
7 changed files with 224 additions and 64 deletions
|
@ -484,6 +484,26 @@ _PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
|
|||
return (PyObject *)tuple;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n)
|
||||
{
|
||||
if (n == 0) {
|
||||
return tuple_get_empty();
|
||||
}
|
||||
|
||||
PyTupleObject *tuple = tuple_alloc(n);
|
||||
if (tuple == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
PyObject **dst = tuple->ob_item;
|
||||
for (Py_ssize_t i = 0; i < n; i++) {
|
||||
PyObject *item = src[i];
|
||||
dst[i] = item;
|
||||
}
|
||||
_PyObject_GC_TRACK(tuple);
|
||||
return (PyObject *)tuple;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
tupleslice(PyTupleObject *a, Py_ssize_t ilow,
|
||||
Py_ssize_t ihigh)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue