[Cython] Fused Types

mark florisson markflorisson88 at gmail.com
Tue May 3 19:04:16 CEST 2011


On 3 May 2011 16:36, Sturla Molden <sturla at molden.no> wrote:
> Den 03.05.2011 16:06, skrev Dag Sverre Seljebotn:
>>
>> Well, if you do something like
>>
>> ctypedef fused_type(float, double) speed_t
>> ctypedef fused_type(float, double) acceleration_t
>>
>> cdef func(speed_t x, acceleration_t y)
>>
>> then you get 4 specializations. Each new typedef gives a new polymorphic
>> type.
>>
>> OTOH, with
>>
>> ctypedef speed_t acceleration_t
>>
>> I guess only 2 specializations.
>>
>> Treating the typedefs in this way is slightly fishy of course. It may hint
>> that "ctypedef" is the wrong way to declare a fused type *shrug*.
>>
>> To only get the "cross-versions" you'd need something like what you wrote
>> + Pauli's "paired"-suggestion.
>>
>
> This is a bloatware generator.
>
> It might not be used right, or it might generate bloat due to small mistakes
> (which will go unnoticed/silent).

Except that we could decide to not generate code for unused
specializations. In any case, the C compile will know it, and issue
warnings if we don't, as the functions are static.

>
> Sturla
>
>
>
> _______________________________________________
> cython-devel mailing list
> cython-devel at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>


More information about the cython-devel mailing list