News for hackers. Stuff that matters.
Re:Tail recursion in Python by zielmicha on Saturday March 17, 2018 @09:56AM (#16606933)
Even Python doesn't need to have stack limit - just make sure C stack is large enough (e.g. using ulimit or pthread_attr_setstacksize) and use `sys.setrecursionlimit(1000000000)`.
Re:Tail recursion in Python by pflanze on Saturday March 17, 2018 @10:23AM (#16607065)
Making the C stack large enough is not solving it on 32 bit architectures with enough physical RAM that you can't/don't want to waste address space. And on 64 bit architectures address space isn't a problem, but the memory from a temporary large stack can't be re-used without swapping the old stack contents out which is slow.
Re:Tail recursion in Python by bagels on Saturday March 17, 2018 @01:11PM (#16607917)
Yes, you could make the stack larger, or, you could avoid needing to keep a gigantic useless stack in memory with this technique in the first place.