3 ms·
Not everyone is using Pydantic (nor do I see the reason to) or even type hints, for that matter. Type hints are great when combined with a good IDE such as Pyc
by wheelerof4te 5y ago
Not everyone is using Pydantic (nor do I see the reason to) or even type hints, for that matter.
Type hints are great when combined with a good IDE such as Pycharm, but are otherwise useless for Python. Sometimes, they are even missleading. Often they don't cover all the call options.
Complicated function calls should be made with keywords anyway. Leave positional only parameters to obvious functions such as pow() or sqrt().
The speed hit should be minimal. You are using Python, where dot access is a much more bigger performance eater than keyword arg functions.
- macintux 5y agoI’ve certainly avoided a nasty bug or two with Python type hints without an IDE. Not sure why you’re so hostile to the idea, the OP didn’t say everyone must use them, just that it’s helpful to be familiar with them.
- wheelerof4te 5y agoI am seemingly hostile to the idea because it is turning Python into somethimg it never should have been. Python does not have the scale to make typing worthwhile, but people are already making it a required Python skill. I this feature is optional, then I should not be required to know it, right? If you want static typing, please use another language that makes use of them to actually speed up the code. Let's keep the docstrings for documentation.
- edgyquant 5y agoYou aren’t required to know it but I don’t think it’s fair for you to say that typing shouldn’t be added just because you don’t want to use it. JavaScript had been made better in the form of typescript and I’d love to use a truly typed python as well.
- peterashford 5y ago100% this. I like Python but I'm working on a large inherited code base and type hints on parameters would have made this much easier. Stronger typing would be a good thing imo.
- nyellin 5y agoYou're right about the performance. When I mentioned scaling I had in mind other issues with a large codebase - not actual performance at runtime. For example, before type hints I found it difficult (even with PyCharm and other IDEs) to safely refactor code. I would end up missing specific usages of an old member name and discover it at runtime when the code raised an exception. In the best case scenario I would find it when running tests. In the worst case, in production. Type hints make this a moot point, at least in real world usage. With type hints the IDE is smart enough to find all references when refactoring.