Possible Duplicate:
Try/catch or validation for speed?
I just started learning Python. I have a question about exception handling mostly because I don't know what exactly happens behind the scene on each exception:
- What is the performance penalty of using exception handling?
- Is it a good practice to use exception handling tricks in a performance code?
From trick I mean something like this code:
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
This code very frequently triggers exceptions.