4 ms·
In python I mostly code in functional style. Even then types helps me a lot. I make a lot of typos or get the order of arguments wrong. Typing helps me a lot he
by rdedev 3y ago
In python I mostly code in functional style. Even then types helps me a lot. I make a lot of typos or get the order of arguments wrong. Typing helps me a lot here especially when I'm doing ML. The last thing I want is my training code to crash after it spent 30nmins processing the data. I find pythons gradual typing a really good middle ground for quick prototyping and the type annotate functions once they are mature enough
- boxed 3y ago> or get the order of arguments wrong There's a simple fix for that, just do keyword argument only everywhere you can. For me the hill I'm willing to die on is that labeled/named/keyword arguments are absolutely necessary and most of the usefulness of types is in fact just a shitty version of labeled arguments (god help you if you have a function where two or more arguments have the same type!)
- rdedev 3y agoThe small downside to using kwargs is just the extra letters needed to call the function but I can live with that. As for args with the same type, you can use phantom types I guess but I haven't explored it much in python. I'm pretty interested in the dfdx library in rust which can type enforce matrix or vector operations on it's shape. Stuff like that would really help me
- boxed 3y agoIt's an advantage imo. Makes the code more readable, and much more robust against bad refactors.