On 5/1/22 00:21, Christopher Barker wrote:
> On Sat, Apr 30, 2022 at 2:17 PM Pablo Alcain wrote:
>> It shows that out of 20k analyzed classes in the selected libraries
(including black,
>> pandas, numpy, etc), ~17% of them could benefit from the usage of
auto-assign syntax.
>
> I only read English, and haven't studied the coe, so I don't know how that
works, but
> assuming it's accurately testing for the simple cases that auto-assigning
could work for;
>
> That's not that much actually -- for approx every six-parameter function,
one of them
> could be auto-assigned.or for every six functions, one could make good use of
auto-
> assignment (and maybe be a dataclass?)
I think you place too much emphasis on dataclasses -- none of my projects use
them, nor could they.
Going through a one of my smaller projects, this is what I found:
- number of `__init__`s: 11
- number of total params (not counting self): 25
- number of those params assigned as-is: 19
- number of `__init__`s where all are assigned as-is: 6
- number of non-`__init__`s where this would useful: 0
> And I'm not trying to be a Negative Nelly here -- I honestly don't know, I
actually
> expected it to be higher than 17% -- but in any case, I think it should be
higher than
> 17% to make it worth a syntax addition.
17% is a massive amount of code.
> But pandas and numpy may not be the least bit representative [...]?
This would not be the first time Python was improved to help the scientific
community.
My own thoughts about the proposal: It seems interesting, and assigning as-is arguments is a chore -- but I'm not sure
using up a token to help only one method per class is a good trade.
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/2GR5G67IKJZDSFU4QYJQF7R4BCZUZPMJ/
Code of Conduct: http://python.org/psf/codeofconduct/