Skip to content

Commit 74f5de3

Browse files
committed
tests/internal_bench/var: Benchmark descriptor access.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent 589c488 commit 74f5de3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import bench
2+
3+
4+
class Descriptor:
5+
def __get__(self, instance, owner=None):
6+
return 20000000
7+
8+
9+
class Foo:
10+
num = Descriptor()
11+
12+
13+
def test(num):
14+
o = Foo()
15+
i = 0
16+
while i < o.num:
17+
i += 1
18+
19+
20+
bench.run(test)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import bench
2+
3+
4+
class Foo:
5+
@property
6+
def num(self):
7+
return 20000000
8+
9+
10+
def test(num):
11+
o = Foo()
12+
i = 0
13+
while i < o.num:
14+
i += 1
15+
16+
17+
bench.run(test)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy