Interesting use of exceptions.
Tail recursion in Python
11–20 of 87 posts
Re: Tail recursion in Python
#12Interesting use of exceptions.
Indeed although generally it's usually a bad idea to misappropriate the exception throwing / handling mechanism for other purposes, as it's probably be less well optimised, performance-wise, than other parts of a VM.
Re: Tail recursion in Python
#13Code snippets you won't see if you have JS disabled: https://gist.github.com/ChrisPenner/c0b3f4feb054daa2f6370d2e... https://gist.github.com/ChrisPenner/c958afbf6e7a763c188d8b83...
Re: Tail recursion in Python
#14Re: Tail recursion in Python
#15lru_cache, from the functools library.
The example given in the docs [0] is:
import functools
@functools.lru_cache(maxsize=None)
def fib(n):
if n
[0] https://docs.python.org/3/library/functools.html#functools.l...Re: Tail recursion in Python
#16Earlier quoted context omitted.
Indeed although generally it's usually a bad idea to misappropriate the exception throwing / handling mechanism for other purposes, as it's probably be less well optimised, performance-wise, than other parts of a VM.
not in python. exceptions for flow control are not looked down upon unless it’s gratuitous usage. many frameworks do exactly this.
Re: Tail recursion in Python
#17Re: Tail recursion in Python
#18Re: Tail recursion in Python
#19Earlier quoted context omitted.
Indeed although generally it's usually a bad idea to misappropriate the exception throwing / handling mechanism for other purposes, as it's probably be less well optimised, performance-wise, than other parts of a VM.
not in python. exceptions for flow control are not looked down upon unless it’s gratuitous usage. many frameworks do exactly this.