[Cython] Fused Types
markflorisson88 at gmail.com
Fri Apr 29 16:59:22 CEST 2011
On 29 April 2011 13:37, Pauli Virtanen <pav at iki.fi> wrote:
> 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.
Hmm, indeed, it's pretty weird. I'm fine with the pairing also,
although I'm still not sure how common this case is, and if we really
want to support it. Wouldn't good old C promotion work for this? e.g.
if the type is either float or double, just declare your variable
> Pauli Virtanen
> cython-devel mailing list
> cython-devel at python.org
More information about the cython-devel