]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 67966 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:49:20 +0000 (23:49 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:49:20 +0000 (23:49 +0000)
svn+ssh://svn.python.org/python/branches/py3k

................
  r67966 | antoine.pitrou | 2008-12-27 21:39:28 +0100 (Sat, 27 Dec 2008) | 9 lines

  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?\195?\169c. 2008) | 3 lines

    Issue #4677: add two list comprehension tests to pybench.
  ........
................

Misc/NEWS
Tools/pybench/Lists.py

index 5d710a6248feba4c6ec51bb12c091276840b8e5b..1703527e07a8dd9f9f5055a21376a9d240ef2ce7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -137,6 +137,11 @@ Library
   support unusual filenames (such as those containing semi-colons) in
   Content-Disposition headers.
 
+Tools/Demos
+-----------
+
+- Issue #4677: add two list comprehension tests to pybench.
+
 Extension Modules
 -----------------
 
index c39687ea17cad58849551d896eea9dc90061d51e..29dabeff5b239a0e7f2541ea6f5600fbd0f186ac 100644 (file)
@@ -293,3 +293,58 @@ class SmallLists(Test):
 
         for i in range(self.rounds):
             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