[Python-checkins] r68261 - in python/branches/release30-maint: Misc/NEWS Tools/pybench/Lists.py

georg.brandl python-checkins at python.org
Sun Jan 4 00:49:21 CET 2009


Author: georg.brandl
Date: Sun Jan  4 00:49:20 2009
New Revision: 68261

Log:
Merged revisions 67966 via svnmerge from 
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.
  ........
................


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Misc/NEWS
   python/branches/release30-maint/Tools/pybench/Lists.py

Modified: python/branches/release30-maint/Misc/NEWS
==============================================================================
--- python/branches/release30-maint/Misc/NEWS	(original)
+++ python/branches/release30-maint/Misc/NEWS	Sun Jan  4 00:49:20 2009
@@ -137,6 +137,11 @@
   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
 -----------------
 

Modified: python/branches/release30-maint/Tools/pybench/Lists.py
==============================================================================
--- python/branches/release30-maint/Tools/pybench/Lists.py	(original)
+++ python/branches/release30-maint/Tools/pybench/Lists.py	Sun Jan  4 00:49:20 2009
@@ -293,3 +293,58 @@
 
         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


More information about the Python-checkins mailing list