setup = """
class A:
    var = {}
    def f1(self):
        x = A.var
    def f2(self):
        x = self.var
a = A()
"""
print('access via class var: %.3f' % timeit.timeit('a.f1()', setup=setup,
    number=100000000))
Performance of accessing class variables in Python