On 04/03/2014 09:46 PM, Paul Mercat wrote:
Hi,

Thank you for your answers.
Yes, your right, my program can't terminate. Maybe my example was not good.
Here is another example where it still crash in my computer :

sys.setrecursionlimit(100000)
def rec(niter):
    if niter == 0:
        return
    rec(niter-1)
rec(50000)
print "hello !" #will never print this !

I think it's not normal that it makes python crash, without saying anything. It should at least display what is the error (probably a stack overflow here).

You can increase the stack size using "ulimit -s 500000". With this setting your code runs for me.

A better idea is to avoid deep recursions, though. See
    http://paulbutler.org/archives/tail-recursion-in-python/
for one approach how to implement tail recursion in python.

HTH,
Christian

--
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to