News for hackers. Stuff that matters.
Re:Strict Python function parameters by wheelerof4te on Sunday January 23, 2022 @12:27PM (#30048086)
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.

Re:Strict Python function parameters by macintux on Sunday January 23, 2022 @02:52PM (#30049806)
I’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.
Re:Strict Python function parameters by wheelerof4te on Sunday January 23, 2022 @03:14PM (#30050012)
I 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.

Re:Strict Python function parameters by edgyquant on Sunday January 23, 2022 @03:26PM (#30050110)
You 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.
Re:Strict Python function parameters by peterashford on Sunday January 23, 2022 @03:52PM (#30050337)
100% 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.
Re:Strict Python function parameters by nyellin on Sunday January 23, 2022 @03:22PM (#30050080)
You'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.