micropython/tests/internal_bench/var-9.5-except_error.py
Anson Mansfield d28844d11b tests/internal_bench/var: Benchmark checked attribute access.
This commit also includes a fix to the `var-6.2-instance-speciallookup.py`
test originally added by 82db5c8 / #16806, as the `__getattr__` method
actually does not trigger a class's special lookups flag as originally
believed.

Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
2025-09-15 16:10:26 +10:00

23 lines
239 B
Python

import bench
class Foo:
pass
def test(num):
o = Foo()
def get():
try:
return o.num
except AttributeError:
return num
i = 0
while i < get():
i += 1
bench.run(test)