Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a013ea

Browse files
committed
Merged revisions 67965 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r67965 | antoine.pitrou | 2008-12-27 21:34:52 +0100 (sam., 27 déc. 2008) | 3 lines Issue #4677: add two list comprehension tests to pybench. ........
1 parent 2056bed commit 2a013ea

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ Library
136136
support unusual filenames (such as those containing semi-colons) in
137137
Content-Disposition headers.
138138

139+
Tools/Demos
140+
-----------
141+
142+
- Issue #4677: add two list comprehension tests to pybench.
143+
139144
Extension Modules
140145
-----------------
141146

Tools/pybench/Lists.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,58 @@ def calibrate(self):
293293

294294
for i in range(self.rounds):
295295
pass
296+
297+
class SimpleListComprehensions(Test):
298+
299+
version = 2.0
300+
operations = 6
301+
rounds = 20000
302+
303+
def test(self):
304+
305+
n = list(range(10)) * 10
306+
307+
for i in range(self.rounds):
308+
l = [x for x in n]
309+
l = [x for x in n if x]
310+
l = [x for x in n if not x]
311+
312+
l = [x for x in n]
313+
l = [x for x in n if x]
314+
l = [x for x in n if not x]
315+
316+
def calibrate(self):
317+
318+
n = list(range(10)) * 10
319+
320+
for i in range(self.rounds):
321+
pass
322+
323+
class NestedListComprehensions(Test):
324+
325+
version = 2.0
326+
operations = 6
327+
rounds = 20000
328+
329+
def test(self):
330+
331+
m = list(range(10))
332+
n = list(range(10))
333+
334+
for i in range(self.rounds):
335+
l = [x for x in n for y in m]
336+
l = [y for x in n for y in m]
337+
338+
l = [x for x in n for y in m if y]
339+
l = [y for x in n for y in m if x]
340+
341+
l = [x for x in n for y in m if not y]
342+
l = [y for x in n for y in m if not x]
343+
344+
def calibrate(self):
345+
346+
m = list(range(10))
347+
n = list(range(10))
348+
349+
for i in range(self.rounds):
350+
pass

0 commit comments

Comments
 (0)