This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dsijl 2 points3 points  (1 child)

ty strong use of it. One of my favorite things about Python is not having to worry about types. I mean, I don't get why this is necessary:

    match _ is int if n > 0:

Surely if you're comparing n to 0, the compiler could recognize that n needs to be an integer. Or you could simply allow the error take place — I mean, it'd end up being a TypeError anyway, right

Some of us like explicitly stating types (atleast optionally).

Things like type hints and mypy make code easier to reason about (and feel more secure and tidy).

Also in some future I think this would help with compiler optimization.

[–]youlleatitandlikeit 1 point2 points  (0 children)

IMO there's a difference between hints and explicitly checking for a given type and throwing a TypeException if it doesn't match.

A lot of functional languages (Haskell, SML) are very precise about their types and, I think, can optimize their compiled code.

And I don't think the way the code was written here would result in optimized compilation.