Commit f01fa458 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

tests/bench/var: Add tests for class/instance var access.

Also compared with method abstraction for accessing instance vars -
it's more than 3 times slower than accessing var directly.
parent aaff82af
import bench
class Foo:
num = 20000000
def test(num):
i = 0
while i < Foo.num:
i += 1
bench.run(test)
import bench
class Foo:
def __init__(self):
self.num = 20000000
def test(num):
o = Foo()
i = 0
while i < o.num:
i += 1
bench.run(test)
import bench
class Foo:
def __init__(self):
self._num = 20000000
def num(self):
return self._num
def test(num):
o = Foo()
i = 0
while i < o.num():
i += 1
bench.run(test)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment