[Python-ideas] [RFC] draft PEP: Dedicated infix operators for matrix multiplication and matrix power

Nathaniel Smith njs at pobox.com
Tue Apr 8 23:17:08 CEST 2014


It's been raised a few times, but the problem is that there's no evidence
that anyone actually needs a short way to perform composition - notice the
composition operation's never even been added to functools. If you do want
to make that case though then there's nothing stopping you :-)
On 8 Apr 2014 22:10, "Michael Mitchell" <epsilonmichael at gmail.com> wrote:

> I haven't been following this thread too closely, so please stop me if
> this has been covered, but has overloading the @ operator as function
> composition been considered yet?
>
> An example would be
>
> filter(a @ b, lst)
>
> as opposed to
>
> filter(lambda x: a(b(x)), lst)
>
>
> On Sun, Apr 6, 2014 at 6:51 PM, Nathaniel Smith <njs at pobox.com> wrote:
>
>> On Mon, Apr 7, 2014 at 12:20 AM, Steven D'Aprano <steve at pearwood.info>
>> wrote:
>> > On Sun, Apr 06, 2014 at 11:02:00PM +0100, Nathaniel Smith wrote:
>> >> On Sun, Mar 16, 2014 at 1:05 PM, Nick Coghlan <ncoghlan at gmail.com>
>> wrote:
>> >> > Aye, but at the moment it makes sense to wait and see if there is
>> even
>> >> > an argument to be had - Nathaniel may decide that even after
>> reviewing
>> >> > the question seriously, he doesn't want to propose a right
>> associative
>> >> > operator :)
>> >>
>> >> And indeed, that does seem to be the way things have worked out :-).
>> >>
>> http://mail.scipy.org/pipermail/numpy-discussion/2014-April/069834.html
>> >
>> > That's a shame in one way -- for anyone using operator overloading to
>> > define their own DSL, there's only ** if you want a right-associative
>> > operator to overload. Still, that's an extremely marginal, and
>> > hypothetical, use-case. Left-associative it is.
>> >
>> > Was that the last blocker for the PEP?
>>
>> Pretty much. Just posted to python-dev:
>>    https://mail.python.org/pipermail/python-dev/2014-April/133791.html
>>
>> -n
>>
>> --
>> Nathaniel J. Smith
>> Postdoctoral researcher - Informatics - University of Edinburgh
>> http://vorpus.org
>> _______________________________________________
>> 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/20140408/519b9cec/attachment.html>


More information about the Python-ideas mailing list