[Numpy-discussion] Possible new multiplication operators for Python

Charles R Harris charlesr.harris@gmail....
Mon Aug 18 12:21:09 CDT 2008


On Mon, Aug 18, 2008 at 10:55 AM, Grégory Lielens <gregory.lielens@fft.be>wrote:

> On Sat, 2008-08-16 at 22:03 -0700, Fernando Perez wrote:
> > Hi all,
> >
> > [ please keep all replies to this only on the numpy list.  I'm cc'ing
> > the scipy ones to make others aware of the topic, but do NOT reply on
> > those lists so we can have an organized thread for future reference]
> >
> > In the Python-dev mailing lists, there were recently two threads
> > regarding the possibility of adding to the language new multiplication
> > operators (amongst others).  This would allow one to define things
> > like an element-wise and a matrix product for numpy arrays, for
> > example:
> >
> > http://mail.python.org/pipermail/python-dev/2008-July/081508.html
> > http://mail.python.org/pipermail/python-dev/2008-July/081551.html
> >
> > It turns out that there's an old pep on this issue:
> >
> > http://www.python.org/dev/peps/pep-0225/
> >
> > which hasn't been ruled out, simply postponed.  At this point it seems
> > that there is room for some discussion, and obviously the input of the
> > numpy/scipy crowd would be very welcome.  I volunteered to host a BOF
> > next week at scipy so we could collect feedback from those present,
> > but it's important that those NOT present at the conference can
> > equally voice their ideas/opinions.
> >
> > So I wanted to open this thread here to collect feedback.  We'll then
> > try to have the bof next week at the conference, and I'll summarize
> > everything for python-dev.  Obviously this doesn't mean that we'll get
> > any changes in, but at least there's interest in discussing a topic
> > that has been dear to everyone here.
> >
> > Cheers,
> >
> > f
>
>
> As one of the original author behind the PEP225, I think this is an
> excellent idea.
> (BTW, thanks for resurrecting this old PEP :-) and considering it
> useful :-) :-) ).
>
> I think I do not need to speak to much for the PEP,  telling that I did
> not change my mind should be enough ;-)...but still, I can not resist
> adding a few considerations:
>
> Demands for Elementwise operators and/or matrix product operator is
> likely to resurface from time to time on Python-dev or Python-idea,
> given that this is a central feature of Matlab and Matlab is a de-facto
> standard when it comes to numeric-oriented interpreted languages (well,
> at least in the engineering world, it is in my experience the biggest
> player by far).
>
> At the time of the original discussion on python-dev and of PEP225
> redaction , I was new to Python and fresh from Matlab, and the default
> behavior of elementwise-product annoyed me a lot. Since then, I have
> learned to appreciate the power of numpy broadcast (Use it extensively
> in my code :-) ), so the default dehavior do not annoy me anymore...
> But I still feel that 2 sets of operator would be very useful
> ( especially in some code which implement directly heavy linear algebra
> formula), the only thing where my point of view has changed is that I
> now think that the Matlab way ( defining * as matrix product and .* as
> elementwise product) is not necessarily the best choice, the reverse
> choice is as valid...
>
> Given the increasing success of Python as a viable alternative, I think
> that settling the Elementwise operator issue is probably a good idea.
> Especially as the Python 3000 transition is maybe a good time to
> investigate syntax changes/extension.
>
>
> >
> > I don't think so, but given that pep 225 exists and is fully fleshed
> > out, I guess it should be considered the starting point of the
> > discussion for reference.  This doesn't mean that modifications to it
> > can't be suggested, but that I'm assuming python-dev will want that as
> > the reference point.  For something as big as this, they would
> > definitely want to work off a real pep.
> >
> > Having said that, I think all ideas are fair game at this point. I
> > personally would like to see it happen, but if not I'd like to see a
> > final pronouncement on the matter rather than seeing pep 225 deferred
> > forever.
> >
>
> I agree 100%. Keeping PEP 225 in limbo is the worst situation imho,
> given that the discussion about elementwise operator (or matrix product)
> keep showing again and again, having a final decision (even if negative)
> would be better. And as I said above, I feel the timing is right for
> this final decision...
>

Tim Hochberg proposed using the call operator for matrix multiplication,
i.e.,

A(B(C))

Which has the advantage of using an existing operator. It looks like
function composition, which isn't that far off the mark if matrices are
looked at as mappings, but might take a bit of getting used to.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080818/378e4823/attachment.html 


More information about the Numpy-discussion mailing list