Re:Pyre: Fast Type Checking for Python
by jchw on Friday May 11, 2018 @02:40PM
(#17049797)
Huh, I thought type annotations were unused at runtime. How can I enable runtime type checking?
[ Parent
| on HN ]
Even Java, which introduced generic types long after the language itself had become standardized and popular, cannot keep generic type information after compilation due to backwards compatibility.
Don't quote me on it, but I believe C# doesn't have this problem.
But the compiler checks for this by default, so you'll get a warning unless you really break the type system.
Re:Pyre: Fast Type Checking for Python
by joshuamorton on Saturday May 12, 2018 @01:47AM
(#17052644)
There are libraries that do magic to do this. Annotations are accessible at runtime, so you can do things like add an implicit import hook that decorates every function or class with a decorator that validates the annotations.
Re:Pyre: Fast Type Checking for Python
by computerfriend on Friday May 11, 2018 @03:14PM
(#17050075)
You can't! Or, I guess you could do something hacky with the #!.