We're working on a way to access overloaded functions at runtime in
https://github.com/python/cpython/pull/31716. This will create a typing.get_overloads() function that returns the overloads for a function.
A few questions came up that I'd like to get feedback on from people who maintain typed codebases:
- The current implementation will make @overload about 6x slower (46 ns to 286 ns). Will this be a problem for users?
- Performance will be worse for functions with a large number of overloads (more than 20 right now). Is this common? (I think the highest overload count for typeshed is builtins.pow(), which has 17.)
- get_overloads() will behave oddly for overloads on functions nested within other functions. Is that something that happens in practice?
_______________________________________________