Monday, July 6, 2009

Increase Python's Recursion Limit

There are in fact two steps. Not only do you need to increase Python's internal recursion limit, you also (probably) will have to increase the stack size allocated to your process.

import resource

# Increase max stack size from 8MB to 512MB
resource.setrlimit(resource.RLIMIT_STACK, (2**29,-1))
sys.setrecursionlimit(10**6)

1 comments:

  1. Thank you very much! You solved my problem.
    ReplyDelete