Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

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?

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to