PEP 835: Shorthand syntax for Annotated type metadata

I am heavy -1 on this. In my opinion, it does not solve any existing real problem. Typing Annotated[] on a keyboard is not that hard and letters are free (especially nowadays).

While it creates several real problems:

  1. It requires to add __matmul__ magic method to most builtin types. For a very niche usecase. It is not something fundamental as | does.
  2. Some existing custom types might already have @ defined to do something different. In this case using them with @ would be impossible and would still require using Annotated directly
  3. It creates complex operator precedence rules int | str @ Metadata and (int | str) @ Metadata are two different things
  4. It would also require us to either port Annotated to C code to use something similar to Py_GenericAlias or to just always call Python code from C code, which is really slow and error-prone

Let’s please do not do this :slight_smile:

However, your PEP work is really impressive and the idea is worth discussing! Thanks a lot for raising this topic.

26 Likes