mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Merged revisions 67965 via svnmerge from
svn+ssh://pythondev@svn.python.org/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. ........
This commit is contained in:
parent
2056bed45e
commit
2a013eac6c
2 changed files with 60 additions and 0 deletions
|
@ -136,6 +136,11 @@ Library
|
||||||
support unusual filenames (such as those containing semi-colons) in
|
support unusual filenames (such as those containing semi-colons) in
|
||||||
Content-Disposition headers.
|
Content-Disposition headers.
|
||||||
|
|
||||||
|
Tools/Demos
|
||||||
|
-----------
|
||||||
|
|
||||||
|
- Issue #4677: add two list comprehension tests to pybench.
|
||||||
|
|
||||||
Extension Modules
|
Extension Modules
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|
|
@ -293,3 +293,58 @@ class SmallLists(Test):
|
||||||
|
|
||||||
for i in range(self.rounds):
|
for i in range(self.rounds):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class SimpleListComprehensions(Test):
|
||||||
|
|
||||||
|
version = 2.0
|
||||||
|
operations = 6
|
||||||
|
rounds = 20000
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
|
||||||
|
n = list(range(10)) * 10
|
||||||
|
|
||||||
|
for i in range(self.rounds):
|
||||||
|
l = [x for x in n]
|
||||||
|
l = [x for x in n if x]
|
||||||
|
l = [x for x in n if not x]
|
||||||
|
|
||||||
|
l = [x for x in n]
|
||||||
|
l = [x for x in n if x]
|
||||||
|
l = [x for x in n if not x]
|
||||||
|
|
||||||
|
def calibrate(self):
|
||||||
|
|
||||||
|
n = list(range(10)) * 10
|
||||||
|
|
||||||
|
for i in range(self.rounds):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class NestedListComprehensions(Test):
|
||||||
|
|
||||||
|
version = 2.0
|
||||||
|
operations = 6
|
||||||
|
rounds = 20000
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
|
||||||
|
m = list(range(10))
|
||||||
|
n = list(range(10))
|
||||||
|
|
||||||
|
for i in range(self.rounds):
|
||||||
|
l = [x for x in n for y in m]
|
||||||
|
l = [y for x in n for y in m]
|
||||||
|
|
||||||
|
l = [x for x in n for y in m if y]
|
||||||
|
l = [y for x in n for y in m if x]
|
||||||
|
|
||||||
|
l = [x for x in n for y in m if not y]
|
||||||
|
l = [y for x in n for y in m if not x]
|
||||||
|
|
||||||
|
def calibrate(self):
|
||||||
|
|
||||||
|
m = list(range(10))
|
||||||
|
n = list(range(10))
|
||||||
|
|
||||||
|
for i in range(self.rounds):
|
||||||
|
pass
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue