[pythran] Re: multiple default arguments

  • From: PIERRE AUGIER <pierre.augier@xxxxxxxxxxxxxxxxxxxxxx>
  • To: pythran <pythran@xxxxxxxxxxxxx>
  • Date: Sun, 8 Nov 2020 14:32:27 +0100 (CET)


----- Mail original -----

De: "serge guelton" <serge.guelton@xxxxxxxxxxxxxxxxxxx>
À: "pythran" <pythran@xxxxxxxxxxxxx>
Envoyé: Samedi 7 Novembre 2020 23:32:20
Objet: [pythran] Re: multiple default arguments

I think it would be good to have a way of allowing only a subset of keyword
arguments, it seems at the moment pythran is not giving the full power of
python (and I did find it a bit counterintuitive that it does not work).

One way of maybe would be to introduce a empty keyword:

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

This has the advantage of making specifying optional arguments more explicit
and would be more in line with the "or" syntax.

One could then also enable the long form:
#pythran export test(float64, int, (int, int))
#pythran export test(float64, empty, (int, int))
#pythran export test(float64, int, empty)

Not sure if empty is the best  keyword here, but can't think of a better one

what about... default? I like the syntax otherwise ;-)

If we follow a bit https://docs.python.org/3/library/typing.html ;(and 
Transonic) with an Optional keyword, it could be written in one line:

#pythran export test(float64, Optional[int], Optional[(int, int)])

Other related posts: