简体   繁体   中英

Python recursion on heap memory

Is there any good methods to place recursion stack on heap to prevent stack overflowing?

Of course, there is method to store own stack and place there function's variables (frame) and just simulate recursion, and, by all appearances, I'm looking for something like decorator, which will do it automatically.

There are a few options here.

  1. Use stackless Python, as the name would suggest it doesn't have this problem.
  2. Build your own stack instead of using recursion
  3. NOT RECOMMENDED Increase the recursion limit https://docs.python.org/2/library/sys.html#sys.setrecursionlimit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM