Robert Vanden Eynde robertve92 at gmail.com
Thu Jan 31 23:58:51 EST 2019

```I love moredots ❤️

With pip install funcoperators, one can implement the *dotmul* iff dotmul
can be implemented as a function.

L *dotmul* 1

Would work.

Or even a simple tweak to the library would allow L *dot* s to be [x*s for
x in L] and L /dot/ s to be [x/s for x in L]"

I'd implement something like "if left is iterable and right is not, apply
[x*y for x in left] else if both are iterable, apply [x*y for x,y in
zip(left, right)] etc."

Iterble

Disclaimer : I'm the creator of funcoperators

On Fri, 1 Feb 2019, 00:23 Steven D'Aprano <steve at pearwood.info wrote:

> On Thu, Jan 31, 2019 at 09:51:20AM -0800, Chris Barker via Python-ideas
> wrote:
>
> > I do a lot of numerical programming, and used to use MATLAB and now
> numpy a
> > lot. So I am very used to "vectorization" -- i.e. having operations that
> > work on a whole collection of items at once.
> [...]
> > You can imagine that for more complex expressions the "vectorized"
> approach
> > can make for much clearer and easier to parse code. Also much faster,
> which
> > is what is usually talked about, but I think the readability is the
> bigger
> > deal.
>
> Julia has special "dot" vectorize operator that looks like this:
>
>      L .+ 1   # adds 1 to each item in L
>
>      func.(L)   # calls f on each item in L
>
> https://julialang.org/blog/2017/01/moredots
>
> The beauty of this is that you can apply it to any function or operator
> and the compiler will automatically vectorize it. The function doesn't
> have to be written to specifically support vectorization.
>
>
> > So what does this have to do with the topic at hand?
> >
> > I know that when I'm used to working with numpy and then need to do some
> > string processing or some such, I find myself missing this
> "vectorization"
> > -- if I want to do the same operation on a whole bunch of strings, why
> do I
> > need to write a loop or comprehension or map? that is:
> >
> > [s.lower() for s in a_list_of_strings]
> >
> > rather than:
> >
> > a_list_of_strings.lower()
>
> Using Julia syntax, that might become a_list_of_strings..lower(). If you
> don't like the double dot, perhaps str.lower.(a_list_of_strings) would
> be less ugly.
>
>
>
> --
> Steven
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190201/f0d27ea7/attachment.html>
```