Reputation: 455
In the Python documentation, it is stated that I can declare type aliases using the following syntax (Python >=3.12):
type Vector = list[float]
but that for backwards compatibility I can also simply write (using the syntax that existed until now):
Vector = list[float]
They do not state any benefit of using the new syntax vs. the former one, and the cons are that it is (very slightly) longer to write, breaks backwards compatibility, and is a new syntax to learn. But I guess they introduced this new syntax for a good reason, what is the typical use case? Should programmers use it or stick to the former way of declaring type aliases?
Upvotes: 0
Views: 51