Using an operator is an interesting idea, and we should probably call it out as 
an alternative in the PEP.
It's not a substitute for the current PEP from the standpoint of typing-sig for 
a few reasons:

(A) We care that the syntax be forward-compatible with supporting named 
arguments, as outlined in the "Extended Syntax" section of Rejected 
Alternatives and I don't think an operator-based syntax would extend to that.

(B) We  like supporting `(**P) -> bool` and `(int, **P) -> bool` for PEP 612 
ParamSpec and Concatenate; this makes it much easier to write types for 
decorators, which are a common use case. It would be tricky to do this using an 
arrow operator.

(C) I'd hesitate to add a dunder method on the tuple type, for reasons already 
mentioned here as well as the fact that it would force us to write unary 
callables - which are the most common kind - as `(int,) >> bool`

------

Separate from the question of arrow types, I wonder if an arrow operator would 
be worthwhile; I don't think it would have to be just for typing.

Discussion probably belongs in a separate thread and I'd be happy to kick one 
off, but it sounds like Steve has a potential use case and I've always found 
the use of `>>`, which feels very low-level because it has baggage as a 
bit-shift, in DSLs to be a little weird. Proposing an operator like `=>` or 
`|>` (my preference would be not to use `->`) might make sense.

The DSLs I'm thinking of (coming from data science) are all, loosely speaking, 
about some kind of pipelining
- dplython uses `>>` to mimic R's pipeline operator, which works well for 
certain data transformations
- At least at one point airflow supported creating DAG links using `>>` to 
represent control flow
- As far as I know Tensorflow doesn't currently use `>>`, but their curried API 
that would lend itself to this
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/NIYHXMFKLN5C47ZIHBF7M4KSFJLZFDMQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to