def accepts_deferred_defaults(f):
    """A decorator that handles DEFERRED arguments.

    Because this wraps the decorated function with another function,
    performance will take a hit.  However, this is unavoidable since the
    arguments are not known until runtime.  Some effort has been made to
    optimize the new function, though it could certainly be improved.
    
    """

    argspec = inspect.getfullargspec(f)
    spec_args = argspec.args
    num_spec_args = len(spec_args)
    defaults = argspec.defaults
    num_bare_args = num_spec_args - len(defaults)
    kwonlyargs = argspec.kwonlyargs
    kwonlydefaults = argspec.kwonlydefaults

    @functools.wraps(f)
    def newfunc(*args, **kwargs):
        args, kwargs = recalculate_arguments(args, kwargs,
                           spec_args, num_spec_args, num_bare_args, defaults,
                           kwonlyargs, kwonlydefaults)
        return f(*args, **kwargs)
    return newfunc
A decorator that handles DEFERRED arguments.

    Because this wraps the decorated function with another function,
    performance will take a hit.  However, this is unavoidable since the
    arguments are not known until runtime.  Some effort has been made to
    optimize the new function, though it could certainly be improved.
    
    
recipes/Python/577786_Smarter_Default_Arguments/recipe-577786.py