Hello,

Currently the user defined functions are mutables, there can be existed
python codes like this:

>>> def foo():
...     pass
...
>>> if not hasattr(foo, 'partial'):
...     foo.partial = {}
...

Adding a new method to function object can break existing projects, but it
is without impact with buit-in functions because they are immutables.


2018-08-09 18:59 GMT+02:00 Michel Desmoulin <desmoulinmic...@gmail.com>:

> 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.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to