From: Stefan Behnel Date: Sat, 27 Mar 2010 06:52:54 +0000 (+0100) Subject: apply flatten-in-list transform also to literal sets X-Git-Tag: 0.13.beta0~251^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1c5fd0c9122f6e0fe191d484fa5ff3ec149a636c;p=cython.git apply flatten-in-list transform also to literal sets --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 0efb23f1..c6e65bfa 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -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 diff --git a/tests/run/inop.pyx b/tests/run/inop.pyx index df5f2aeb..e836f4cc 100644 --- a/tests/run/inop.pyx +++ b/tests/run/inop.pyx @@ -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 *')