To solve this, I had the wild idea of using multithreading to give me multiple stacks. I didn't honestly know if this would work before I tried it. I hate multithreading generally, but this is a very basic version of that. I'm sure others can improve on it. In my final product I implement multithreading into my backtracking algorithm.
import threading
def recurThread(x,y,z):
if x <= 1:
y.append(x)
if z[0] != 1:
new_y = []
z[0] -= 1
new_t = threading.Thread(target=recurThread, args=(900, new_y, z))
new_t.start()
new_t.join()
y += new_y
else:
return
y.append(x)
return recurThread(x-1, y, z)
y = []
z = [50]
x = threading.Thread(target=recurThread, args=(900, y, z))
x.start()
x.join()
total = 0
print(len(y))
for i in y:
total += i
print(total)
This is the basic idea. Things to note are that if you want to get values back from the threads, you need to store them (and pass them) as mutable objects like lists.
The other thing to note if you're unfamiliar with threads (like I was) is that you need to .start() your thread. More importantly, .join() will wait for the thread to finish before continuing. This allows for the program to be run normally, just with this instance of a thread allowing you to cheat the stack limit.