I believe that the overload in the typing module is not how function overloading should be implemented. What it does is it helps us declare functions with the same name and different args but restricts us from invoking them.
Since we are not allowed to invoke an overload decorated function it becomes extremely painful to have just one function definition that handles all overloaded behavior and fill it with ifs and elses.
In this article, I tried to tackle this very situation where we could also invoke an @overload decorated function and thus eradicate the need of having one definition to cover everything.
Thanks.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Not sure if you are aware of this, but the standard library already provides this functionality in the
typing
module. You can see the docs hereI believe that the
overload
in thetyping
module is not how function overloading should be implemented. What it does is it helps us declare functions with the same name and different args but restricts us from invoking them.Since we are not allowed to invoke an
overload
decorated function it becomes extremely painful to have just one function definition that handles all overloaded behavior and fill it withif
s andelse
s.In this article, I tried to tackle this very situation where we could also invoke an
@overload
decorated function and thus eradicate the need of having one definition to cover everything.Thanks.