This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rhettinger
Recipients gregory.p.smith, ncoghlan, rhettinger, serhiy.storchaka
Date 2021-05-02.01:29:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619918941.06.0.356097322861.issue44003@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2021-05-02 01:29:01rhettingersetrecipients: + rhettinger, gregory.p.smith, ncoghlan, serhiy.storchaka
2021-05-02 01:29:01rhettingersetmessageid: <1619918941.06.0.356097322861.issue44003@roundup.psfhosted.org>
2021-05-02 01:29:01rhettingerlinkissue44003 messages
2021-05-02 01:29:00rhettingercreate