Ian Bell, 07.08.2012 05:55:
> Is there any way to do overloaded functions in cython? I have a PXD file
> that demonstrates what I am trying to do:
>
> cdef extern from "CoolProp.h":
>
> double _Props "Props"(char *Output,char Name1, double Prop1, char
> Name2, double Prop2, char * Ref)
> double _Props1 "Props"(char * Ref, char *Output)
>
> #Function prototypes
> cpdef double Props(bytes Parameter, bytes param1, float value1, bytes
> param2, float value2, bytes Fluid)
> cpdef double Props(bytes Fluid, bytes Parameter)
>
> I would then write my implementation in a PYX file and all should be well.
Hmm, you mean that you want to implement these in Cython and export them to
other modules? This is not about wrapping C++ implemented code, right?
Cython doesn't currently support this. You can use optional arguments in
cdef functions, though.
Such a feature can't be hard to add, given that we have already support for
C++ types anyway. You wouldn't declare a cname though (your "Props" string
above), Cython would mangle the internal names for you. However, exporting
them so that other modules can use them might turn out to be tricky because
all Cython versions you use would have to come up with the same mangled
public name.
Stefan