From: Stefan Behnel Date: Sat, 4 Dec 2010 09:40:12 +0000 (+0100) Subject: make 'complex' the C double complex type instead of Python's complex object type X-Git-Tag: 0.14.alpha0~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d9ce56c7b08274eab94534b4e65219e7d5718542;p=cython.git make 'complex' the C double complex type instead of Python's complex object type --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 09a9ffdf..593f9f6a 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -786,6 +786,14 @@ class CSimpleBaseTypeNode(CBaseTypeNode): error(self.pos, "can only complexify c numeric types") type = PyrexTypes.CComplexType(type) type.create_declaration_utility_code(env) + elif type is Builtin.complex_type: + # Special case: optimise builtin complex type into C's + # double complex. The parser cannot do this (as for the + # normal scalar types) as the user may have redeclared the + # 'complex' type. Testing for the exact type here works. + type = PyrexTypes.c_double_complex_type + type.create_declaration_utility_code(env) + self.complex = True if type: return type else: diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 1ff5a021..2c302fc5 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -2318,7 +2318,7 @@ modifiers_and_name_to_type = { (1, 0, "double"): c_double_type, (1, 1, "double"): c_longdouble_type, - (1, 0, "complex"): c_float_complex_type, + (1, 0, "complex"): c_double_complex_type, # C: float, Python: double => Python wins (1, 0, "floatcomplex"): c_float_complex_type, (1, 0, "doublecomplex"): c_double_complex_type, (1, 1, "doublecomplex"): c_longdouble_complex_type,