In article <[EMAIL PROTECTED]>, Matteo wrote: >This last approach could, at least theoretically, create an arbitrarily >long list of polys, without overflowing any kind of stack. In practice, >python does not seem to perform tail recursion optimizations, and conks >out after makepolys(997) on my machine. >
You can find out the conking-out limit and change it, within reason. >>> import sys >>> help (sys.getrecursionlimit) [...] >>> help (sys.setrecursionlimit) [...] Here is a recipe for tail recursion optimization at ASPN: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 Python doesn't do any kind of tail recursion optimization by default because Guido has decided it shouldn't (at least so far). I'm sure it has been discussed in detail in Python development forums & lists, but I don't know those details. This Google search is a start, but it gives too many hits for me to shift through now: http://www.google.fi/search?q=site%3Apython.org+tail+recursion Pka -- http://mail.python.org/mailman/listinfo/python-list