[Cython] Fused Types

Greg Ewing greg.ewing at canterbury.ac.nz
Wed May 4 01:07:03 CEST 2011


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.

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.

-- 
Greg


More information about the cython-devel mailing list