News for hackers. Stuff that matters.
Re:Tail recursion in Python by harryf on Saturday March 17, 2018 @07:47AM (#16606566)
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 by throwaway110116 on Saturday March 17, 2018 @08:07AM (#16606607)
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 by icebraining on Saturday March 17, 2018 @08:20AM (#16606642)
Even the language itself does this: if a generator that is being processed by a for loop returns (rather than yield), the language will raise a StopIteration exception, which the for loop with catch and use as a signal that it should exit.
Re:Tail recursion in Python by oneweekwonder on Saturday March 17, 2018 @08:45AM (#16606713)
Yes! the more I dive into general py libraries the more I see `try: import pylib2 except: pylib2 = None` etc,