F
10

Just learned that Python's default recursion limit is only 1000 calls

I found this out when my Fibonacci function crashed at 999 recursions and I totally didn't expect such a low number for a 'beginner friendly' language, has anyone else hit this wall while learning?
3 comments

Log in to join the discussion

Log In
3 Comments
the_piper
the_piper1mo ago
Oh COME ON, right? Python is supposed to be the "hold your hand" language and then it just HITS you with a recursion brick wall at a thousand calls? That's like taking training wheels off a bike and then pushing the kid down a hill. I was trying to do a simple tree traversal once and it blew up on like the 850th call, I was SO mad. The worst part is that error message is super cryptic too, it just says "RecursionError" and leaves you googling for twenty minutes. They really need to bump that number up or at least warn you in the docs that recursion is basically a trap for newbies.
1
the_susan
the_susan1mo ago
My friend hit this at 900 calls and spent an hour thinking his code was broken.
4
claire_davis31
850 calls for a simple tree traversal? Were you writing it recursively on purpose, or did you just not realize how fast Python eats through its stack?
1