[pythran] Re: follow up on None type default kwarg errors question on defaults in tables

  • From: Serge Guelton <serge.guelton@xxxxxxxxxxxxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Wed, 30 Dec 2020 13:15:20 +0100

On Tue, Dec 29, 2020 at 11:42:42PM +0100, Jochen S wrote:

When trying to fix the compile error I have with the None type keywords I had 
a
closer look at tables and the generation/translation process. I can fix my
issues by changing remove_named_arguments.py to always include all default
arguments not just up to the last keyword argument. The nice thing is that 
this
means defaults in python and C++  don't necessarily have to match this way.

I don't think that's the way to go. Considering arguments with default None
value, you should provide an overload for those. for instance in
empty_likes.hpp:


  template <class E, class dtype>
  auto empty_like(E const &expr, dtype d = dtype())
      -> decltype(empty(sutils::getshape(expr), d));

  template <class E>
  auto empty_like(E const &expr, types::none_type d = builtins::None)
      -> decltype(empty(sutils::getshape(expr),
                        types::dtype_t<typename E::dtype>()));

Hope it helps?

Other related posts: