summaryrefslogtreecommitdiffstatshomepage
path: root/tests/internal_bench/funcall-3-funcall-local.py
blob: d922888685984ad77a3a63bf007b802267c142f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Function call overhead test
# Perform the same trivial operation as calling function, cached in a
# local variable. This is commonly known optimization for overly dynamic
# languages (the idea is to cut on symbolic look up overhead, as local
# variables are accessed by offset, not by name)
import bench


def f(x):
    return x + 1


def test(num):
    f_ = f
    for i in iter(range(num)):
        a = f_(i)


bench.run(test)