From b9310773756f40f77e075f221a90dd41e6964efc Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Tue, 16 Nov 2021 11:01:57 +0000 Subject: bpo-45753: Make recursion checks more efficient. (GH-29524) * Uses recursion remaining, instead of recursion depth to speed up check against recursion limit. --- Python/pystate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index a9ed08a7e34..8df28078f2a 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -636,9 +636,9 @@ new_threadstate(PyInterpreterState *interp, int init) tstate->interp = interp; - tstate->recursion_depth = 0; + tstate->recursion_limit = interp->ceval.recursion_limit; + tstate->recursion_remaining = interp->ceval.recursion_limit; tstate->recursion_headroom = 0; - tstate->stackcheck_counter = 0; tstate->tracing = 0; tstate->root_cframe.use_tracing = 0; tstate->root_cframe.current_frame = NULL; -- cgit v1.2.3