On 05/03/2011 03:51 PM, Stefan Behnel wrote:
mark florisson, 03.05.2011 15:17:
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".

So, what would you have to do in order to get a "float, double" and
"double, float" version then? Could you get that with

ctypedef fused_type(double, float) floating_df
ctypedef fused_type(float, double) floating_fd

cdef func(floating_df x, floating_fd y):

?

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.


Dag Sverre
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel

Reply via email to