timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt=
    """try:
 a=d[1]
except KeyError:
 a=10""")
timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt=
    """try:
 a=d[2]
except KeyError:
 a=10""")
timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt='a=d.get(1, 10)')
timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt='a=d.get(2, 10)')
timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt=
    """if 1 in d:
 a=d[1]
else:
 a=10""")
timeit.timeit(setup='d={1:2, 3:4, 5:6, 7:8, 9:0}', stmt=
    """if 2 in d:
 a=d[2]
else:
 a=10""")
словарь python и значения по умолчанию