mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Use static inline function Py_EnterRecursiveCall() (#91988)
Currently, calling Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() may use a function call or a static inline function call, depending if the internal pycore_ceval.h header file is included or not. Use a different name for the static inline function to ensure that the static inline function is always used in Python internals for best performance. Similar approach than PyThreadState_GET() (function call) and _PyThreadState_GET() (static inline function). * Rename _Py_EnterRecursiveCall() to _Py_EnterRecursiveCallTstate() * Rename _Py_LeaveRecursiveCall() to _Py_LeaveRecursiveCallTstate() * pycore_ceval.h: Rename Py_EnterRecursiveCall() to _Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() and _Py_LeaveRecursiveCall()
This commit is contained in:
parent
14243369b5
commit
d716a0dfe2
15 changed files with 524 additions and 521 deletions
|
@ -7,6 +7,7 @@
|
|||
#define PY_SSIZE_T_CLEAN
|
||||
#include <Python.h>
|
||||
#include <stdbool.h>
|
||||
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
|
||||
#include "pycore_exceptions.h" // struct _Py_exc_state
|
||||
#include "pycore_initconfig.h"
|
||||
#include "pycore_object.h"
|
||||
|
@ -1097,7 +1098,7 @@ exceptiongroup_split_recursive(PyObject *exc,
|
|||
for (Py_ssize_t i = 0; i < num_excs; i++) {
|
||||
PyObject *e = PyTuple_GET_ITEM(eg->excs, i);
|
||||
_exceptiongroup_split_result rec_result;
|
||||
if (Py_EnterRecursiveCall(" in exceptiongroup_split_recursive")) {
|
||||
if (_Py_EnterRecursiveCall(" in exceptiongroup_split_recursive")) {
|
||||
goto done;
|
||||
}
|
||||
if (exceptiongroup_split_recursive(
|
||||
|
@ -1105,10 +1106,10 @@ exceptiongroup_split_recursive(PyObject *exc,
|
|||
construct_rest, &rec_result) < 0) {
|
||||
assert(!rec_result.match);
|
||||
assert(!rec_result.rest);
|
||||
Py_LeaveRecursiveCall();
|
||||
_Py_LeaveRecursiveCall();
|
||||
goto done;
|
||||
}
|
||||
Py_LeaveRecursiveCall();
|
||||
_Py_LeaveRecursiveCall();
|
||||
if (rec_result.match) {
|
||||
assert(PyList_CheckExact(match_list));
|
||||
if (PyList_Append(match_list, rec_result.match) < 0) {
|
||||
|
@ -1234,11 +1235,11 @@ collect_exception_group_leaves(PyObject *exc, PyObject *leaves)
|
|||
/* recursive calls */
|
||||
for (Py_ssize_t i = 0; i < num_excs; i++) {
|
||||
PyObject *e = PyTuple_GET_ITEM(eg->excs, i);
|
||||
if (Py_EnterRecursiveCall(" in collect_exception_group_leaves")) {
|
||||
if (_Py_EnterRecursiveCall(" in collect_exception_group_leaves")) {
|
||||
return -1;
|
||||
}
|
||||
int res = collect_exception_group_leaves(e, leaves);
|
||||
Py_LeaveRecursiveCall();
|
||||
_Py_LeaveRecursiveCall();
|
||||
if (res < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue