[Python-Dev] Re: Re: PEP 318: Decorators last before colon

Skip Montanaro skip at pobox.com
Thu Apr 1 13:05:59 EST 2004


    >> (Has any consideration been given to an actual metafunc mechanism
    >> more directly analogous to metaclasses, that would be given the
    >> *pieces* of a would-be function (name, param names, default args,
    >> code body, etc), so that there would not necessarily ever be a
    >> standard function object?)

    Guido> Deconstructing a function like that is too invasive -- I don't
    Guido> want to touch the calling sequence, for example, because it's so
    Guido> performance critical.  None of the people arguing for decorators
    Guido> has shown a use case for that either.  However, if you really
    Guido> want to do that, you *can* take the function apart and construct
    Guido> a new one using the 'new' module.

One thing that occurred to me is that a function's func_name attribute might
be made read-write so that decorator functions can easily make that aspect
of a function wrapper behave the same as the original function.  Calling
new.function() shouldn't be required in such simple cases.

Skip



More information about the Python-Dev mailing list