<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Sat, Feb 2, 2019 at 3:31 PM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The comprehension version isn't awful:<br>
<br>
[(a*2).name.upper() for a in seq]<br>
<br>
but not all vectorized operations can be written as a chain of calls on <br>
a single sequence.<br></blockquote><div><br></div><div>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</div><div><br></div><div> [(expr with x1, ..., xn substituted for v1, ..., vn)</div><div> for x1, ..., xn in zip(v1, ..., vn)]<br><br></div><div>which seems not much worse than the auto-vectorized version (with or without special syntax).</div><div><br></div><div>Haskell (GHC) has parallel list comprehension syntax (<a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#parallel-list-comprehensions">https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#parallel-list-comprehensions</a>) 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.<br></div></div></div></div></div></div>