timeit.timeit(setup='a=1;b=1', stmt=
    """try:
 a/b
except ZeroDivisionError:
 pass""")
timeit.timeit(setup='a=1;b=0', stmt=
    """try:
 a/b
except ZeroDivisionError:
 pass""")
timeit.timeit(setup='a=1;b=1', stmt='if b!=0:\n a/b')
timeit.timeit(setup='a=1;b=0', stmt='if b!=0:\n a/b')
Using try vs if in python