Message392651
I don't really like it. Carrying forward these attributes isn't the norm for wrapping functions.
The __defaults__ argument is normally only used where it has an effect rather than in a wrapper where it doesn't. Given that it is mutable, it invites a change that won't work. For example:
>>> def pow(base, exp=2):
return base ** exp
>>> pow.__defaults__
(2,)
>>> pow.__defaults__ = (3,)
>>> pow(2)
8
Also, an introspection function can only meaningfully use defaults when accompanied by the names of the fields:
>>> pow.__code__.co_varnames
('base', 'exp')
However, these aren't visible by directly introspecting the wrapper.
FWIW, we've never had a user reported issue regarding the absence of __defaults__. If ain't broke, let's don't "fix" it.
Nick and Serhiy, any thoughts? |
|
Date |
User |
Action |
Args |
2021-05-02 01:29:01 | rhettinger | set | recipients:
+ rhettinger, gregory.p.smith, ncoghlan, serhiy.storchaka |
2021-05-02 01:29:01 | rhettinger | set | messageid: <1619918941.06.0.356097322861.issue44003@roundup.psfhosted.org> |
2021-05-02 01:29:01 | rhettinger | link | issue44003 messages |
2021-05-02 01:29:00 | rhettinger | create | |
|