Open nbecker opened 1 year ago
optional args can be specified with a ?
but that would not solve your case. Don't know about kwargs.
#pythran export F(int?, float?, str?)
def F(a=1, b=2.0, c='hello'):
print ('a:', a, 'b:', b, 'c:', c)
can be called with e.g. F(5)
, F(3, 4.0)
etc, but not with F(b=3.0)
.
I think there is an incompatibility between functions with default parameter values and pythran specifications. Here is an example:
In python, any combination of values could be specified or omitted: F(a=1) F(b=2.5) F(b=3.0, c='bye') There would appear to be no way to capture this in pythran_export specifications.
For now, my workaround is write python wrapper functions that interpret the passed parameters and defaults and then call the pythran function with all parameters passed.
But this is not ideal
At least it would be better if somehow the wrapper function could be included in the same source file instead of needing a 2nd source file for the wrapper.