def _make_decorator(measuring_func):
def _decorator(name = None, metric = call_default):<EOL><INDENT>def wrapper(func):<EOL><INDENT>name_ = name if name is not None else func.__module__ + '<STR_LIT:.>' +func.__name__<EOL>class instrument_decorator(object): <EOL><INDENT>@wraps(func)<EOL>def __call__(self, *args, **kwargs):<EOL><INDENT>return measuring_func(func(*args, **kwargs), name_, metric)<EOL><DEDENT>def __get__(self, instance, class_):<EOL><INDENT>name_ = name if name is not None else"<STR_LIT:.>".join((class_.__module__, class_.__name__, func.__name__))<EOL>@wraps(func)<EOL>def wrapped_method(*args, **kwargs):<EOL><INDENT>return measuring_func(func(instance, *args, **kwargs), name_, metric)<EOL><DEDENT>return wrapped_method<EOL><DEDENT><DEDENT>return instrument_decorator()<EOL><DEDENT>return wrapper<EOL><DEDENT>return _decorator<EOL>
morass of closures for making decorators/descriptors