2

Before you mark me as a duplicate, other questions are about Python ints being too long too convert into C longs, not C ints. When I try and do this:

sys.setrecursionlimit(10000000000)

I get this:

Traceback (most recent call last):
  File "<pyshell#44>", line 1, in <module>
    sys.setrecursionlimit(10000000000)
OverflowError: Python int too large to convert to C int

is there any way to surpass this, or override it?

User 12692182
  • 927
  • 5
  • 16
  • 5
    There's no point having a recursion limit if you allow it to get anywhere close to C's max int. I once had a justifiable reason to set it at 2000 in a DP algorithm, but otherwise I wouldn't mess with it. XY-problem? You may want to look at using a data structure; there may be some duplicates here. – Kenny Ostrom Feb 26 '20 at 23:13
  • I know. I was just curious, because I've run in to similar errors before – User 12692182 Feb 26 '20 at 23:23

1 Answers1

3

No. The variable is the type that it is. You can't set it to a value bigger than what it can hold. You'll have to live with a recursion depth of a mere two billion and change, instead of ten billion; I suspect you'll run out of memory before you get that many call frames deep anyway.

hobbs
  • 223,387
  • 19
  • 210
  • 288