timeit.timeit("""try:
    raise KeyError
except KeyError:
    pass""",
    number=1000000)
timeit.timeit("""try:
    raise KeyError
except:
    pass""", number=1000000)
Exceptions catching performance in python