summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2008-12-27 20:34:52 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2008-12-27 20:34:52 (GMT)
commite555f581dc3d23b0d305b6a74bb292ed8cb674f3 (patch)
treedf7428f91a0836c735228cc4fa9451f92827cb9b
parent1ffbfbc5666cc304ca00c6da297431e9d2aee6a1 (diff)
downloadcpython-e555f581dc3d23b0d305b6a74bb292ed8cb674f3.zip
cpython-e555f581dc3d23b0d305b6a74bb292ed8cb674f3.tar.gz
cpython-e555f581dc3d23b0d305b6a74bb292ed8cb674f3.tar.bz2
Issue #4677: add two list comprehension tests to pybench.
-rw-r--r--Misc/NEWS5
-rw-r--r--Tools/pybench/Lists.py55
2 files changed, 60 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 64ff406..3fc5664 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -190,6 +190,11 @@ Library
- Issue #4730: Fixed the cPickle module to handle correctly astral characters
when protocol 0 is used.
+Tools/Demos
+-----------
+
+- Issue #4677: add two list comprehension tests to pybench.
+
Build
-----
diff --git a/Tools/pybench/Lists.py b/Tools/pybench/Lists.py
index 67760db..6c297a3 100644
--- a/Tools/pybench/Lists.py
+++ b/Tools/pybench/Lists.py
@@ -293,3 +293,58 @@ class SmallLists(Test):
for i in xrange(self.rounds):
pass
+
+class SimpleListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ n = range(10) * 10
+
+ for i in xrange(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 = range(10) * 10
+
+ for i in xrange(self.rounds):
+ pass
+
+class NestedListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ m = range(10)
+ n = range(10)
+
+ for i in xrange(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 = range(10)
+ n = range(10)
+
+ for i in xrange(self.rounds):
+ pass