[issue44790] Recursion causes Crash
Dennis Sweeney
report at bugs.python.org
Fri Jul 30 23:45:53 EDT 2021
Dennis Sweeney <sweeney.dennis650 at gmail.com> added the comment:
Indeed, this behavior is documented at https://docs.python.org/3/library/sys.html?highlight=setrecursionlimit#sys.setrecursionlimit : "a too-high limit can lead to a crash".
I'd recommend refactoring to use iteration rather than recursion:
def fact(n):
product = 1
for i in range(1, n+1):
product *= i
return product
----------
nosy: +Dennis Sweeney
resolution: -> not a bug
stage: -> resolved
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44790>
_______________________________________
More information about the Python-bugs-list
mailing list