News for hackers. Stuff that matters.
Re:Why type hinting sucks (/r/Python) by adrian17 on Saturday February 11, 2023 @09:16AM (#34752436)
> but you’d be more likely to just go straight to the fully-correct solution that this example is never able to reach in Python

Couldn't this be done if Python added C++ Concepts-like facilities? As in, something like (extremely ugly oversimplified un-pythonic pseudocode):

    def slow_add(a: Any, b: Any) requires({a+b}) -> decltype(a+b):
        return a + b
This is still effectively duck typed, but since the type checker is able to typecheck `a+b`, it should be able to handle `slow_add(a, b)` given these extra hints.

There are no comments on this comment yet.