Skip to content

Commit fc79fce

Browse files
committed
- changes from running autopep8 via pre-commit
1 parent ae0f403 commit fc79fce

File tree

7 files changed

+174
-76
lines changed

7 files changed

+174
-76
lines changed

benchmarks/micro.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@
1414
for i in range(100)
1515
]
1616

17+
1718
class IWideInheritance(*ifaces):
1819
"""
1920
Inherits from 100 unrelated interfaces.
2021
"""
2122

23+
2224
class WideInheritance(object):
2325
pass
26+
27+
2428
classImplements(WideInheritance, IWideInheritance)
2529

30+
2631
def make_deep_inheritance():
2732
children = []
2833
base = Interface
@@ -32,10 +37,14 @@ def make_deep_inheritance():
3237
children.append(child)
3338
return children
3439

40+
3541
deep_ifaces = make_deep_inheritance()
3642

43+
3744
class DeepestInheritance(object):
3845
pass
46+
47+
3948
classImplements(DeepestInheritance, deep_ifaces[-1])
4049

4150

@@ -58,6 +67,7 @@ def make_implementer(iface):
5867
classImplements(c, iface)
5968
return c
6069

70+
6171
implementers = [
6272
make_implementer(iface)
6373
for iface in ifaces
@@ -70,6 +80,7 @@ def make_implementer(iface):
7080

7181
INNER = 100
7282

83+
7384
def bench_in(loops, o):
7485
t0 = pyperf.perf_counter()
7586
for _ in range(loops):
@@ -78,6 +89,7 @@ def bench_in(loops, o):
7889

7990
return pyperf.perf_counter() - t0
8091

92+
8193
def bench_sort(loops, objs):
8294
import random
8395
rand = random.Random(8675309)
@@ -92,6 +104,7 @@ def bench_sort(loops, objs):
92104

93105
return pyperf.perf_counter() - t0
94106

107+
95108
def bench_query_adapter(loops, components, objs=providers):
96109
components_queryAdapter = components.queryAdapter
97110
# One time through to prime the caches
@@ -111,16 +124,16 @@ def bench_getattr(loops, name, get=getattr):
111124
t0 = pyperf.perf_counter()
112125
for _ in range(loops):
113126
for _ in range(INNER):
114-
get(Interface, name) # 1
115-
get(Interface, name) # 2
116-
get(Interface, name) # 3
117-
get(Interface, name) # 4
118-
get(Interface, name) # 5
119-
get(Interface, name) # 6
120-
get(Interface, name) # 7
121-
get(Interface, name) # 8
122-
get(Interface, name) # 9
123-
get(Interface, name) # 10
127+
get(Interface, name) # 1
128+
get(Interface, name) # 2
129+
get(Interface, name) # 3
130+
get(Interface, name) # 4
131+
get(Interface, name) # 5
132+
get(Interface, name) # 6
133+
get(Interface, name) # 7
134+
get(Interface, name) # 8
135+
get(Interface, name) # 9
136+
get(Interface, name) # 10
124137
return pyperf.perf_counter() - t0
125138

126139

@@ -168,6 +181,7 @@ def bench_iface_call_w_conform_return_non_none_not_provided(loops):
168181
iface(inst)
169182
return pyperf.perf_counter() - t0
170183

184+
171185
def _bench_iface_call_simple(loops, inst):
172186
t0 = pyperf.perf_counter()
173187
for _ in range(loops):
@@ -224,28 +238,28 @@ def bench_iface_call_no_conform_provided_deep(loops):
224238
)
225239

226240
runner.bench_time_func(
227-
'read __module__', # stored in C, accessed through __getattribute__
241+
'read __module__', # stored in C, accessed through __getattribute__
228242
bench_getattr,
229243
'__module__',
230244
inner_loops=INNER * 10
231245
)
232246

233247
runner.bench_time_func(
234-
'read __name__', # stored in C, accessed through PyMemberDef
248+
'read __name__', # stored in C, accessed through PyMemberDef
235249
bench_getattr,
236250
'__name__',
237251
inner_loops=INNER * 10
238252
)
239253

240254
runner.bench_time_func(
241-
'read __doc__', # stored in Python instance dictionary directly
255+
'read __doc__', # stored in Python instance dictionary directly
242256
bench_getattr,
243257
'__doc__',
244258
inner_loops=INNER * 10
245259
)
246260

247261
runner.bench_time_func(
248-
'read providedBy', # from the class, wrapped into a method object.
262+
'read providedBy', # from the class, wrapped into a method object.
249263
bench_getattr,
250264
'providedBy',
251265
inner_loops=INNER * 10
@@ -258,17 +272,20 @@ def bench_iface_call_no_conform_provided_deep(loops):
258272
inner_loops=1
259273
)
260274

275+
261276
def populate_components():
262277
def factory(o):
263278
return 42
264279

265280
pop_components = Components()
266281
for iface in ifaces:
267282
for other_iface in ifaces:
268-
pop_components.registerAdapter(factory, (iface,), other_iface, event=False)
283+
pop_components.registerAdapter(
284+
factory, (iface,), other_iface, event=False)
269285

270286
return pop_components
271287

288+
272289
runner.bench_time_func(
273290
'query adapter (all trivial registrations)',
274291
bench_query_adapter,

0 commit comments

Comments
 (0)