[Cython] Fused Types

mark florisson markflorisson88 at gmail.com
Wed May 4 09:26:53 CEST 2011


On 4 May 2011 01:07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> mark florisson wrote:
>
>> cdef func(floating x, floating y):
>>    ...
>>
>> you get a "float, float" version, and a "double, double" version, but
>> not "float, double" or "double, float".
>
> It's hard to draw conclusions from this example because
> it's degenerate. You don't really need multiple versions of a
> function like that, because of float <-> double coercions.

It's only degenerate if you want a real world example, and not one
that provides a simple answer to your original question...

> A more telling example might be
>
>  cdef double dot_product(floating *u, floating *v, int length)
>
> By your current rules, this would give you one version that
> takes two float vectors, and another that takes two double
> vectors.
>
> But if you want to find the dot product of a float vector and
> a double vector, you're out of luck.

Sure, so you can create two fused types. I do however somewhat like
your proposal with the indexing in the definition.

> --
> Greg
> _______________________________________________
> 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