Awesome idea!

I wrote a typed single-dispatch some time ago: https://github.com/dry-python/classes
Maybe it would be helpful to you.

The biggest problem I had was generics support. For example, what would happen in case of:

```python
from numbers import Real, Integral

@dispatch()
def __lt__(lhs: list[Real], rhs: list[Real]) -> bool: ...
```

I had troubles with it. And my version does not support generics with type arguments (because that's how isinstance works which we rely on during runtime).

The second problem is protocols (generic protocols are the hardest). What should happen in a case of:

```python
@dispatch()
def __lt__(lhs: int, rhs: int) -> bool: ...

@dispatch()
def __lt__(lhs: SupportsInt, rhs: SupportsInt) -> bool: ...
```

Should it be dependent on the order of declarations?
Or should we check the most specific types first? How to determine the most specific types?

This is really a deep topic!

Best,
Nikita Sobolev
https://github.com/sobolevn

чт, 29 окт. 2020 г. в 00:43, Neil Girdhar <mistersheik@gmail.com>:
Hi everyone,

My friend and I have been interested in multiple dispatch for a while, and we noticed that it might be worth considering using it to resolve some fundamental difficulties type-checkers have understanding binary operators.  We wrote up a collab summarizing our ideas: https://colab.research.google.com/drive/1-HQa5GOmV-uhTbv6EgnMfJYVgwuYMIrQ#scrollTo=IOYiwp6iATZf

I initially posted a short version of this idea to python-ideas, but Guido suggested I flesh out the idea and post it here.  Looking forward to everyone's insight and comments,

Best,

Neil
_______________________________________________
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/
Member address: n.a.sobolev@gmail.com