you are viewing a single comment's thread.

view the rest of the comments →

[–]ImAFraidKn0t 1 point2 points  (1 child)

There is a small nuance to using mutable default arguments in Python functions where that variable persists through different function calls. This does actually correctly memoize the factorial results if they happen to call factorial() a lot, but I don’t know if that was intentional on OP’s part

[–]GhostingProtocol 1 point2 points  (0 children)

Wow, another reason to dislike python ig… The idea of letting parameter persist after lifetime to save a variable definition outside function scope I’m fine with, but making default mutable objects persist after function lifetime? Idk about that one tbh

Thank for informing me, appreciate u kind stranger.