[Cython] Fused Types

Pauli Virtanen pav at iki.fi
Fri Apr 29 13:37:54 CEST 2011

Fri, 29 Apr 2011 12:53:06 +0200, mark florisson wrote:
> But if we just allow that for fused types, then couldn't we simply do
> ctypedef cython.fused_type(float, double) real_t
> cdef real_plus_one(real_t complex a):
>     real_t b = a.real
>     return b + 1
> ? Then you don't need to pair anything. Perhaps we could introduce
> real_t as a type, just like numeric and floating. So I guess
> special-casing complex sounds fine with me.

Special-casing for complex sounds ugly to me; "complex float" 
is a type name in the same way as "long int" is, and writing 
"real_t complex" feels a bit like writing "int_t long".

But of course, if this feature is really only needed for declaring
complex variants of real types, then how it is done doesn't matter
so much. But, IMHO, such a special casing would be a somewhat weird
language feature.

Pauli Virtanen

More information about the cython-devel mailing list