Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7197

Infinite recursion and sys.setrecursionlimit stops script without any errors

$
0
0

I wanted to do a few little experiments via measuring runtimes, especially comparing three implementations of fibonacci: recursive, lru_cache and linear (with linear space). I accidentally implemented the lru_ache version in a way that created infinite recursion:

@lru_cache(None)def fibo_cache(n):    return fibo_cache(n)

(basically I wanted to reuse the recursive version first, but then I found that it would not apply cache to recursive calls, so changed it to this)

This caused my program to just simply stop without any errors or messages. If launched from IDLE, it created RESTART: Shell lines and go back to REPL

On the documentation page of lru_cache I found no menntion of stopping the script.

Is this the intended behaviour, or a possible bug?

EDIT:

I've set the recursion limit to 500_000 via sys. I'd still expect an exception, however. It's documentation says

This should be done with care, because a too-high limit can lead to a crash.

But does not say I'll get no message. This might be the case, however.


Viewing all articles
Browse latest Browse all 7197

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>