Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursion effect
#1
Does recursion cause any trouble in Python?
Reply
#2
It can. Python has a limit on the size of the interpreter stack. Very deep recursion can cause an error by exceeding that limit. The limit can be found with sys.getrecursionlimit() and modified with sys.setrecursionlimit(). Note that if you set it too high, that can overflow the underlying C stack size.

Also, while some languages like Erlang can get around the stack limit by using tail recursion, Python is not set up to do that.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Followings are caused by Recursion in Python:
  • It can lead to consuming more time for calling a Function.
  • Needs more function calls.
  • Each function call stores a state variable to the program stack- consumes memory, can cause memory overflow.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020