base_method: for i in r: index_inline_test_method : v = None if 'a' not in d else d['a'] 2 function calls in 0.070 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.070 0.070 0.070 0.070 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} index_var_test_method : if c in d: v = d[c] else: v = None 2 function calls in 0.069 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.069 0.069 0.069 0.069 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} index_test_method : if 'a' in d: v = d['a'] else: v = None 2 function calls in 0.064 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.064 0.064 0.064 0.064 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} get_var_method : v = d.get(c) 100002 function calls in 0.115 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.092 0.092 0.115 0.115 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 100000 0.023 0.000 0.023 0.000 {method 'get' of 'dict' objects} index_method : try: v = d['a'] except KeyError: v = None 2 function calls in 0.050 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.050 0.050 0.050 0.050 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} index_var_method : try: v = d[c] except KeyError: v = None 2 function calls in 0.054 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.054 0.054 0.054 0.054 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} get_method : v = d.get('a') 100002 function calls in 0.127 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.097 0.097 0.127 0.127 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} 100000 0.030 0.000 0.030 0.000 {method 'get' of 'dict' objects} index_var_inline_test_method : v = None if c not in d else d[c] 2 function calls in 0.071 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.071 0.071 0.071 0.071 :1() 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}