[pythran] Re: multiple default arguments

  • From: Serge Guelton <serge.guelton@xxxxxxxxxxxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Fri, 6 Nov 2020 09:24:23 +0100

On Fri, Nov 06, 2020 at 09:03:34AM +0100, Jochen S wrote:

Hi

if I understand #1243 correctly I cannot export a function with  multiple
default arguments, but only use the second or third. Something along the lines
of:

#pythran export test(float64, int (int, int))
#pythran export test(float64, (int, int))
#pythran export test(float64, int)
#pythran export test(float64)
def test(x, i=0, t=(1,2)):
    print(x)
    print(i)
    print(t)


At least that doesn't seem to work for me. and just specifying the first and
last line I would always have to either pass i and t or none of them correct?

Is there are way of working around this, except for writing a python wrapper?

Hi Jochen,

Your understanding is correct.

#pythran export test(float64, int, (int, int))
#pythran export test(float64, int)
#pythran export test(float64)

these three are legits, but not that one

#pythran export test(float64, (int, int))

without more info, there's no way for pythran to compute whether this is

i = (int, int) and t = (1,2)

or

i = 0 and t = (int, int)

we would need a new syntax for that. Any proposition?

Other related posts: