[Python-ideas] Add 'composable' decorator to functools (with @ matrix multiplication)

Ivan Levkivskyi levkivskyi at gmail.com
Wed May 6 23:25:05 CEST 2015


Dear Yann,

The two options that you mentioned are indeed equivalent (the function
application is much tighter that @),
but note that z would be a partial-like object.

Of course for this to work, not only the first function must be decorated
with @composable, but also all multi-argument functions.


On 6 May 2015 at 21:32, Yann Kaiser <kaiser.yann at gmail.com> wrote:

> On Wed, 6 May 2015 at 09:10 Ivan Levkivskyi <levkivskyi at gmail.com> wrote:
>
>> Dear Guido,
>>
>> My original idea was to make the composable functions auto-curried
>> (similar to proposed here
>> http://code.activestate.com/recipes/52902-function-composition/ as
>> pointed out by Steve) so that
>>
>> my_fun = square @ add(1)
>> my_fun(x)
>>
>> evaluates to
>>
>> square(add(1,x))
>>
>
> This breaks the (IMO) fundamental expectation that
>
>     z = add(1)
>     my_fun = square @ z
>
> is equivalent to
>
>     my_fun = square @ add(1)
>
> -Yann
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150506/bcbf60ac/attachment.html>


More information about the Python-ideas mailing list