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

Christopher Barker pythonchb at gmail.com
Sun Feb 10 16:51:58 EST 2019


On Sun, Feb 10, 2019 at 10:06 AM Kyle Lahnakoski <klahnakoski at mozilla.com>
wrote:

> but none of these are as elegant or readable as the vectorized syntax
>
>      result = process.(vector .+ sequence) .* items
>
> I've a bit lost track of who is proposing what, but this looks like an
extra set of operators: ".*",  ".+" etc. for vectorized operations.

So I want to point out that is was proposed way back when for numpy:

MATLAB for instance, has a the usual operators: *, +, etc meaning "matrix
math", and then another set of "itemwise" operators with a "dot form: .*,
.+ . - for "itemwise" math.

numpy, on the other other had uses the regular operators for itemwise
operations (what we're calling vectorized here), and Python lacked an extra
set of operators that could be used for matrix math. Adding another full
set (.*, .+, etc) was discussed A LOT and the Python community did not want
that.

Then someone had the brilliant observation that matrix multiplication was
teh only one that was really useful and presto! the @ operator was born.

Anyway -- just suggesting that a full set of "vectorized" operators will
liley see a lot of resistance. And for my part, having mean the opposite of
what it does for numpy would be unfortunate as well.

> I am interested in vector operations.  I have situations where I want to
perform some conceptually simple operations on a series of
not-defined-by-me objects to make a series of conclusions.  The
calculations can be done succinctly in SQL, but Python makes them difficult.

Bringing real world examples of this would be a good idea for this
discussion

I'm inclined to think that something like pandas (maybe more generally SQL
-like that the number crunching focus of Pandas) might be better than new
syntax for the language -- but only real examples will tell.

I don't work with data like that much, but I"m pretty sure I've seen Python
packages that to attempt to address these use cases. (that being querying
and processing tabular data)

-CHB


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190210/f04700c2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jpgkifbeadmcaigm.png
Type: image/png
Size: 62836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190210/f04700c2/attachment-0001.png>


More information about the Python-ideas mailing list