1# Function call overhead test 2# Perform the same trivial operation as calling function, cached in a 3# local variable. This is commonly known optimization for overly dynamic 4# languages (the idea is to cut on symbolic look up overhead, as local 5# variables are accessed by offset, not by name) 6import bench 7 8 9def f(x): 10 return x + 1 11 12 13def test(num): 14 f_ = f 15 for i in iter(range(num)): 16 a = f_(i) 17 18 19bench.run(test) 20