[Python-ideas] Vectorization [was Re: Add list.join() please]

James Lu jamtlu at gmail.com
Thu Feb 7 14:18:42 EST 2019


Here are some alternate syntaxes.

These are all equivalent to len(print(list)).

(len | print)(list)
(len |> print)(list)
(print <| len)(list)
print <| len << list
list >> print <| len
list >> len |> print


## Traditional argument order 
print <| len << list

## Stored functions 
print_lengths = len | print
print_lengths = len |> print
print_lengths = print <| len

These can be called using callable syntax.
These can be called using << syntax.
These can be called using >> syntax.
## Lightweight traditional syntax order
(print | len)()

# Explanation
The pipeline operator (|, |>, <|) create an object.

That object implements, depending on the chosen implementation, some combination of the __call__ operator, the __rshift__ operator, and/or the __lshift__ operator.
—
I am not proposing Python has all these operators at the same time, just putting these ideas out there for discussion. 


More information about the Python-ideas mailing list