mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
bpo-45753: Make recursion checks more efficient. (GH-29524)
* Uses recursion remaining, instead of recursion depth to speed up check against recursion limit.
This commit is contained in:
parent
9bf2cbc4c4
commit
b931077375
10 changed files with 50 additions and 43 deletions
|
@ -37,7 +37,8 @@ get_recursion_depth(PyObject *self, PyObject *Py_UNUSED(args))
|
|||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
|
||||
/* subtract one to ignore the frame of the get_recursion_depth() call */
|
||||
return PyLong_FromLong(tstate->recursion_depth - 1);
|
||||
|
||||
return PyLong_FromLong(tstate->recursion_limit - tstate->recursion_remaining - 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue