News for hackers. Stuff that matters.
Re:Why type hinting sucks (/r/Python) by pwdisswordfishc on Saturday February 11, 2023 @05:50AM (#34751181)
It seems the problem stems from a poorly defined purpose of the API, which is to say, from this being a shitty example. Why would someone use slow_add instead of the plus operator anyway?
Re:Why type hinting sucks (/r/Python) by selimnairb on Saturday February 11, 2023 @06:18AM (#34751326)
Yeah, it seemed like a straw man example. For me, type hints are most useful as a sort of meta domain specific language. Type hints can be hard to get right for abstract data types, and it’s often not worth it (and I rarely write ADTs in Python, relying on what the rich standard library offers). I find type hints to be very useful for “annotating” domain-specific code that carries out my application’s “business” logic. This rarely includes things like basic arithmetic functions.