[Cython] Fused Types

mark florisson markflorisson88 at gmail.com
Tue May 3 15:19:42 CEST 2011


On 3 May 2011 15:17, mark florisson <markflorisson88 at gmail.com> wrote:
> On 3 May 2011 07:47, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>> I'm a bit confused about how fused types combine to
>> create further fused types. If you have something
>> like
>>
>>  ctypedef struct Vector:
>>    floating x
>>    floating y
>>    floating z
>>
>> then is it going to generate code for all possible
>> combinations of types for x, y and z?
>>
>> That's probably not what the user intended -- it's
>> more likely that he wants *two* versions of type
>> Vector, one with all floats and one with all doubles.
>> But without explicit type parameters, there's no way
>> to express that.
>>
>> I worry that you're introducing a parameterised type
>> system in a half-baked way here without properly
>> thinking through all the implications.
>>
>> --
>> Greg
>>
>> _______________________________________________
>> cython-devel mailing list
>> cython-devel at python.org
>> http://mail.python.org/mailman/listinfo/cython-devel
>>
>
> Currently you cannot use them at all in structs, only as cdef function
> argument types. Then if you have
>
> cdef func(floating x, floating y):
>    ...
>
> you get a "float, float" version, and a "double, double" version, but
> not "float, double" or "double, float". When and if support for
> structs is there, it will work the same way as with functions.
>

However the difference here is a ctypedef:

ctypedef floating *floating_p

Now a parameter with floating_p may have a different specialized base
type than the specialized type of floating.


More information about the cython-devel mailing list