I am against this. First, syntax like this formal_to_actual: [[int]] = [] is IMO quite cryptic, and can quickly become unreadable in real-world code. This is of course subjective, but my opinion is quite strong here. Also, in real-world code type names are much longer that `List` or `Dict`, I see `List[FrameworkNameModelFactoryConfigRule]` every day. So relative win in terms of keystrokes will be minimal. Second, this idea targets people who are already familiar with types. For ordinary Python devs, learning types is already hard (this is just a fact, I have seen many experience Python devs making basic mistakes). Although current syntax is verbose, it is very homogeneous, just a bunch of nested `Type[OneType, OtherType]`. Instead of trying to invent a fancy syntax, we need to write a good extended tutorial about types in Python and polish unexpected/inconsistent *semantics*. Third, we have more important problems than suboptimal syntax. Some people think verbosity is a big problem of statically typed languages, but this is IMO not the case. For example, after trying Scala, and Kotlin (both claim to be less verbose than Java), I still find Java easiest to write/read. I think a big problem of statically typed languages is that one needs to "fight" the language often -- if you can't express the type of your function it will not compile. This is something people never do in Python. It means our type system should be expressive enough to easily express types in idiomatic Python code. This is far from being true currently, and this is IMO of of the reasons why people don't use types, rather than them being verbose. Finally, I also don't think the current syntax is optimal, I would rather have `Optional` -> `Opt`, `Callable` -> `Call`, plus maybe some _limited_ amount of special forms (for example only unions and tuples, because they are actually special). But this is still relatively minor and can be partially fixed by `from typing import Optional as Opt`, etc. -- Ivan On Tue, 20 Nov 2018 at 10:23, Elazar <elazarg@gmail.com> wrote:
בתאריך יום ג׳, 20 בנוב׳ 2018, 10:10, מאת Sebastian Rittau < srittau@rittau.biz>:
<snip>
On a more general note, Python's type annotation syntax is quite verbose, often cumbersome to write and hard to read, due to the original requirement of not introducing new syntax. Working towards a more concise shorthand syntax is worthwhile, in my opinion.
Allowing
v: [int] x: (int, str) y: {str} z: {str: Any}
Could be a start.
Elazar _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mm3/mailman3/lists/typing-sig.python.org/