coady / multimethod

Multiple argument dispatching.
https://coady.github.io/multimethod
Other
284 stars 23 forks source link

multimethod "forgets" keyword only arguments #86

Closed svaningelgem closed 1 year ago

svaningelgem commented 1 year ago

Hi,

In multimethod there is this code, and I'm wondering why it doesn't take into account the kwargs?

    def __call__(self, *args, **kwargs):
        """Resolve and dispatch to best method."""
        return self[tuple(map(self.get_type, args))](*args, **kwargs)

Is it because it's unknown what is the right order for the kwargs? Also in the get_types method, the keyword_only arguments will not be considered as well. And arguments with default values are not considered as well... So, I'm just wondering why this design decision was made?

Because in my current usecase I have a need for this and was wondering about the logic behind its current implementation. Otherwise I could take a shot at 'fixing' the issue as I see it?

Thanks

coady commented 1 year ago

Keyword argument dispatch is implemented on multidispatch. And it is based on the initial definition, for performance reasons detailed in #34.

svaningelgem commented 1 year ago

Thanks a lot! That wasn't clear to me from the outset.