[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power
Nick Coghlan
ncoghlan at gmail.com
Mon Mar 24 14:28:06 CET 2014
On 24 March 2014 22:06, Steven D'Aprano <steve at pearwood.info> wrote:
> On Sun, Mar 23, 2014 at 08:48:49PM -0700, Devin Jeanpierre wrote:
>> On Sun, Mar 23, 2014 at 8:12 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> > I think it is highly unlikely that people will be frightened off from
>> > overloading @ by the name. If people happily use __lt__ for subset
>> > checking, which is *nothing* like less-than,
>>
>> Actually, no. <, or "less than", is the exact way it's spelled for any
>> partial order, and subset relations are probably the most famous
>> non-numeric example of a partial order.
>
> I will accept that subsets are an example of partial order and so I was
> wrong to say that that it has nothing to do with __lt__ and __gt__.
I normally let python-ideas subthreads run indefinitely without
commenting, but in this case... *really* not a productive tangent :)
Ellipsis, extended slicing and memory views were added to the core
language and C API definitions for the numeric computing folks without
a compelling stdlib use case (at least at the time). Adding __matmul__
for their benefit really isn't much of a stretch, and it makes the
distinction *they* care about clear (__mul__ = element-wise
multiplication, __matmul__ = matrix multiplication). Previous
proposals along these lines failed because they overgeneralised
without compelling benefits from the extra complexity, while this one
hits the sweet spot of solving the *actual* problem to be solved with
just some minor technical details to work out.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list