[Cython] Fused Types

mark florisson markflorisson88 at gmail.com
Tue May 3 15:17:39 CEST 2011


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.


More information about the cython-devel mailing list