Nov-10-2022, 12:48 PM
Since Python 3.11 we got Zero Cost Exceptions.
If no exception is raised, there is nearly no loss in speed.
Only if an exception raises, it's slower.
It's ok to use try... except. Catching Exceptions too early is sometimes a problem.
It depends on the program itself and its organization.
+ it is OK to use Exceptions for control flow. Python is doing it aswell.
Fun fact 1: The control-flow of for-loops is realized with
Fun fact 2: A generator returns its result with a
If no exception is raised, there is nearly no loss in speed.
Only if an exception raises, it's slower.
It's ok to use try... except. Catching Exceptions too early is sometimes a problem.
It depends on the program itself and its organization.
+ it is OK to use Exceptions for control flow. Python is doing it aswell.
Fun fact 1: The control-flow of for-loops is realized with
StopIteration
. The iterator raises the StopIteration
, if the iterator is exhausted.Fun fact 2: A generator returns its result with a
StopIteration
and the result is stored in exception.args[0]
.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!