2 ms·
I don't think you can draw that conclusion from that code. I've been using Python for a few years and moved some projects to static type checking. It's not alwa
by gjulianm 6y ago
I don't think you can draw that conclusion from that code. I've been using Python for a few years and moved some projects to static type checking. It's not always worth the cost in every situation, of course. For such a simple script I wouldn't add type checking. But for larger projects where there are multiple classes and a lot of types, I've found that the effort is very much worth it: a lot of type errors are found faster (some of them hadn't been caught by unit testing), the code becomes more consistent and easier to read, and developing is easier if you have an IDE that understands the types and gives you appropriate suggestions.
It's also worth it in plumbing code, as it tends to be more difficult to test properly and having types will catch a whole class of errors.
The fact that the program at the bottom of the article can be simplified is not an issue of typing, in fact static typing could also be used in your approach without any issue.