On Sat, Feb 2, 2019 at 3:31 PM Steven D'Aprano firstname.lastname@example.org wrote:
The comprehension version isn't awful:
[(a*2).name.upper() for a in seq]
but not all vectorized operations can be written as a chain of calls on a single sequence.
If they are strictly parallel (no dot products) and you know when writing the code which variables hold vectors, then (denoting the vector variables by v1, ..., vn) you can always write
[(expr with x1, ..., xn substituted for v1, ..., vn) for x1, ..., xn in zip(v1, ..., vn)]
which seems not much worse than the auto-vectorized version (with or without special syntax).
Haskell (GHC) has parallel list comprehension syntax ( https://downloads.haskell.org/%7Eghc/latest/docs/html/users_guide/glasgow_ex...) so you don't have to explicitly call zip. I wouldn't mind having that in Python but I don't know what the syntax would be.