bpo-45256: Avoid C calls for most Python to Python calls. (GH-28937)

* Avoid making C calls for most calls to Python functions.

* Change initialize_locals(steal=true) and _PyTuple_FromArraySteal to consume the argument references regardless of whether they succeed or fail.
This commit is contained in:
Mark Shannon 2021-10-18 09:57:24 +01:00 • committed by GitHub
parent fd03917786
commit 70945d57e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 128 additions and 180 deletions

View file

@ -490,9 +490,11 @@ _PyTuple_FromArraySteal(PyObject *const *src, Py_ssize_t n)
if (n == 0) {
return tuple_get_empty();
}
PyTupleObject *tuple = tuple_alloc(n);
if (tuple == NULL) {
for (Py_ssize_t i = 0; i < n; i++) {
Py_DECREF(src[i]);
}
return NULL;
}
PyObject **dst = tuple->ob_item;