3 ms·
> Python could detect inconsistent type hints at runtime. But why would it? Because the programmer explicitly intended a contract which is being violated, whic
by reikonomusha 5y ago
> Python could detect inconsistent type hints at runtime. But why would it?
Because the programmer explicitly intended a contract which is being violated, which would in turn indicate a bug.
- joshuamorton 5y agoDo you think other languages should do the same, because very few do any kind of runtime type checking (e.g. bounds checking) due to the performance penalty. Why focus specifically on python's lack of runtime type checking? Anecdotally, my code in python is functionally fully typechecked and runtime type checking would solely penalize me by slowing down my code. There's no need for it because the type checker correctly proves the soundness of the program's types, in exactly the same way that Java's or C++'s do. The point is precisely that you don't need to suffer the costs of runtime type checking if you have a solid typechecker. Lisp's approach here is worse than the one adopted by python/js/ts/go/etc.