diff --git a/src/core/main.c b/src/core/main.c index 7e836dab3..9c4654f5e 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -94,6 +94,13 @@ run_python_simple_inner(char* code) int numpy_patch_init(); +int +get_python_stack_depth() +{ + PyThreadState* tstate = PyThreadState_GET(); + return tstate->recursion_depth; +} + /** * Bootstrap steps here: * 1. Initialize init_dict so that runPythonSimple will work. diff --git a/src/js/pyodide.js b/src/js/pyodide.js index bb57ace83..914f2a80b 100644 --- a/src/js/pyodide.js +++ b/src/js/pyodide.js @@ -154,7 +154,7 @@ function fixRecursionLimit() { recurse(); } catch (err) {} - let recursionLimit = Math.min(depth / 50, 400); + let recursionLimit = Math.min(depth / 25, 500); Module.runPythonSimple( `import sys; sys.setrecursionlimit(int(${recursionLimit}))` );