diff options
| author | Victor Stinner <vstinner@python.org> | 2022-05-04 13:30:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-04 13:30:23 +0200 |
| commit | d716a0dfe2d1029111db393afaecdb04cc4093de (patch) | |
| tree | 2644817d65b365bf1dd2872661948d1b564bff32 /Objects/abstract.c | |
| parent | 14243369b5f80613628a565c224bba7fb3fcacd8 (diff) | |
| download | cpython-git-d716a0dfe2d1029111db393afaecdb04cc4093de.tar.gz | |
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()
Diffstat (limited to 'Objects/abstract.c')
| -rw-r--r-- | Objects/abstract.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 9034737235..93987c201b 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -3,7 +3,7 @@ #include "Python.h" #include "pycore_abstract.h" // _PyIndex_Check() #include "pycore_call.h" // _PyObject_CallNoArgs() -#include "pycore_ceval.h" // _Py_EnterRecursiveCall() +#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate() #include "pycore_object.h" // _Py_CheckSlotResult() #include "pycore_pyerrors.h" // _PyErr_Occurred() #include "pycore_pystate.h" // _PyThreadState_GET() @@ -2546,7 +2546,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls) break; } assert(n >= 2); - if (Py_EnterRecursiveCall(" in __issubclass__")) { + if (_Py_EnterRecursiveCall(" in __issubclass__")) { Py_DECREF(bases); return -1; } @@ -2556,7 +2556,7 @@ abstract_issubclass(PyObject *derived, PyObject *cls) break; } } - Py_LeaveRecursiveCall(); + _Py_LeaveRecursiveCall(); Py_DECREF(bases); return r; } @@ -2633,7 +2633,7 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls if (PyTuple_Check(cls)) { /* Not a general sequence -- that opens up the road to recursion and stack overflow. */ - if (_Py_EnterRecursiveCall(tstate, " in __instancecheck__")) { + if (_Py_EnterRecursiveCallTstate(tstate, " in __instancecheck__")) { return -1; } Py_ssize_t n = PyTuple_GET_SIZE(cls); @@ -2646,19 +2646,19 @@ object_recursive_isinstance(PyThreadState *tstate, PyObject *inst, PyObject *cls break; } } - _Py_LeaveRecursiveCall(tstate); + _Py_LeaveRecursiveCallTstate(tstate); return r; } PyObject *checker = _PyObject_LookupSpecial(cls, &_Py_ID(__instancecheck__)); if (checker != NULL) { - if (_Py_EnterRecursiveCall(tstate, " in __instancecheck__")) { + if (_Py_EnterRecursiveCallTstate(tstate, " in __instancecheck__")) { Py_DECREF(checker); return -1; } PyObject *res = PyObject_CallOneArg(checker, inst); - _Py_LeaveRecursiveCall(tstate); + _Py_LeaveRecursiveCallTstate(tstate); Py_DECREF(checker); if (res == NULL) { @@ -2725,7 +2725,7 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) if (PyTuple_Check(cls)) { - if (_Py_EnterRecursiveCall(tstate, " in __subclasscheck__")) { + if (_Py_EnterRecursiveCallTstate(tstate, " in __subclasscheck__")) { return -1; } Py_ssize_t n = PyTuple_GET_SIZE(cls); @@ -2737,19 +2737,19 @@ object_issubclass(PyThreadState *tstate, PyObject *derived, PyObject *cls) /* either found it, or got an error */ break; } - _Py_LeaveRecursiveCall(tstate); + _Py_LeaveRecursiveCallTstate(tstate); return r; } checker = _PyObject_LookupSpecial(cls, &_Py_ID(__subclasscheck__)); if (checker != NULL) { int ok = -1; - if (_Py_EnterRecursiveCall(tstate, " in __subclasscheck__")) { + if (_Py_EnterRecursiveCallTstate(tstate, " in __subclasscheck__")) { Py_DECREF(checker); return ok; } PyObject *res = PyObject_CallOneArg(checker, derived); - _Py_LeaveRecursiveCall(tstate); + _Py_LeaveRecursiveCallTstate(tstate); Py_DECREF(checker); if (res != NULL) { ok = PyObject_IsTrue(res); |
