summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/internal_bench/var-6.2-instance-speciallookup.py19
-rw-r--r--tests/internal_bench/var-6.3-instance-property.py17
-rw-r--r--tests/internal_bench/var-6.4-instance-descriptor.py20
-rw-r--r--tests/internal_bench/var-6.5-instance-getattr.py16
4 files changed, 72 insertions, 0 deletions
diff --git a/tests/internal_bench/var-6.2-instance-speciallookup.py b/tests/internal_bench/var-6.2-instance-speciallookup.py
new file mode 100644
index 000000000..71845f3aa
--- /dev/null
+++ b/tests/internal_bench/var-6.2-instance-speciallookup.py
@@ -0,0 +1,19 @@
+import bench
+
+
+class Foo:
+ def __init__(self):
+ self.num = 20000000
+
+ def __getattr__(self, name): # just trigger the 'special lookups' flag on the class
+ pass
+
+
+def test(num):
+ o = Foo()
+ i = 0
+ while i < o.num:
+ i += 1
+
+
+bench.run(test)
diff --git a/tests/internal_bench/var-6.3-instance-property.py b/tests/internal_bench/var-6.3-instance-property.py
new file mode 100644
index 000000000..b4426ef79
--- /dev/null
+++ b/tests/internal_bench/var-6.3-instance-property.py
@@ -0,0 +1,17 @@
+import bench
+
+
+class Foo:
+ @property
+ def num(self):
+ return 20000000
+
+
+def test(num):
+ o = Foo()
+ i = 0
+ while i < o.num:
+ i += 1
+
+
+bench.run(test)
diff --git a/tests/internal_bench/var-6.4-instance-descriptor.py b/tests/internal_bench/var-6.4-instance-descriptor.py
new file mode 100644
index 000000000..b4df69f87
--- /dev/null
+++ b/tests/internal_bench/var-6.4-instance-descriptor.py
@@ -0,0 +1,20 @@
+import bench
+
+
+class Descriptor:
+ def __get__(self, instance, owner=None):
+ return 20000000
+
+
+class Foo:
+ num = Descriptor()
+
+
+def test(num):
+ o = Foo()
+ i = 0
+ while i < o.num:
+ i += 1
+
+
+bench.run(test)
diff --git a/tests/internal_bench/var-6.5-instance-getattr.py b/tests/internal_bench/var-6.5-instance-getattr.py
new file mode 100644
index 000000000..3b2ef6721
--- /dev/null
+++ b/tests/internal_bench/var-6.5-instance-getattr.py
@@ -0,0 +1,16 @@
+import bench
+
+
+class Foo:
+ def __getattr__(self, name):
+ return 20000000
+
+
+def test(num):
+ o = Foo()
+ i = 0
+ while i < o.num:
+ i += 1
+
+
+bench.run(test)