[Python-ideas] Syntactic sugar to declare partial functions
Michel Desmoulin
desmoulinmichel at gmail.com
Thu Aug 9 12:59:20 EDT 2018
I'd rather have functools.partial() to be added as a new method on
function objects.
>
> fromfunctools importpartial
>
>
> def add(x:int,y:int)->int:
> returnx +y
>
>
> add_2 = partial(add,2)
>
Would become:
add_2 = add.partial(2)
Nothing to change on the parser, no obscure syntax for future readers,
and we can get the opportunity of rewriting partial() in C as right now
it is amazingly way, way slower than a lambda.
More information about the Python-ideas
mailing list