Segmentation Fault For Deep Recursion Upon Going From Python 2.6 To 2.7
Solution 1:
Because your Python uses C stack, it's overflowed. setrecursionlimit
can't extend cstack size. it just make limit to raise exception before cstack overflows. Python's recursion has limited depth. Success in 2.6 is just lucky case.
You should change your code from recursion to iterative style or use stackless python(or PyPy). Read http://docs.python.org/2/library/sys.html#sys.setrecursionlimit
Solution 2:
You probably overflow stack with deep recursion somewhere in Python implementation. You may try changing stack dept with sys.setrecursionlimit
Another possibility is that you exhaust dynamic memory. Recursion is normally more taxing.
You had more luck with Python 2.6. Previous version required less memory for your algorithm.
Python isn't a functional language and doesn't optimise tail recursion. Rewriting the algorithm iteratively may be a better approach.
Post a Comment for "Segmentation Fault For Deep Recursion Upon Going From Python 2.6 To 2.7"