apply flatten-in-list transform also to literal sets
authorStefan Behnel <scoder@users.berlios.de>
Sat, 27 Mar 2010 06:52:54 +0000 (07:52 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 27 Mar 2010 06:52:54 +0000 (07:52 +0100)
Cython/Compiler/Optimize.py
tests/run/inop.pyx

index 0efb23f1cbd982967513fa878c3d79fdd7d45825..c6e65bfa996e4102257f34db810339ac14972aab 100644 (file)
@@ -591,7 +591,9 @@ class FlattenInListTransform(Visitor.VisitorTransform, SkipDeclarations):
         else:
             return node
 
-        if not isinstance(node.operand2, (ExprNodes.TupleNode, ExprNodes.ListNode)):
+        if not isinstance(node.operand2, (ExprNodes.TupleNode,
+                                          ExprNodes.ListNode,
+                                          ExprNodes.SetNode)):
             return node
 
         args = node.operand2.args
index df5f2aebfbfe0c0d3822b3d421ac9d23f2ea80a9..e836f4ccacc89faf12703a0fcec39b256b8d54af 100644 (file)
@@ -52,16 +52,36 @@ def k(a):
     cdef int result = a in [1,2,3,4]
     return result
 
-def m(int a):
+def m_list(int a):
     """
-    >>> m(2)
+    >>> m_list(2)
     1
-    >>> m(5)
+    >>> m_list(5)
     0
     """
     cdef int result = a in [1,2,3,4]
     return result
 
+def m_tuple(int a):
+    """
+    >>> m_tuple(2)
+    1
+    >>> m_tuple(5)
+    0
+    """
+    cdef int result = a in (1,2,3,4)
+    return result
+
+def m_set(int a):
+    """
+    >>> m_set(2)
+    1
+    >>> m_set(5)
+    0
+    """
+    cdef int result = a in {1,2,3,4}
+    return result
+
 def n(a):
     """
     >>> n('d *')