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.

2
  • 1
    Did you change the recursion limit in sys? Commented Aug 21, 2020 at 18:42
  • @superbrain rain edited question Commented Aug 21, 2020 at 18:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.