{"action":"created","issue":{"url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/50","labels_url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/50/labels{/name}","comments_url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/50/comments","events_url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/50/events","html_url":"https://github.com/GrahamDumpleton/wrapt/issues/50","id":107761540,"number":50,"title":"Performing computations after the decorator is applied to the function but before the decorated function is called","user":{"login":"ceridwen","id":8268008,"avatar_url":"https://avatars.githubusercontent.com/u/8268008?v=3","gravatar_id":"","url":"https://api.github.com/users/ceridwen","html_url":"https://github.com/ceridwen","followers_url":"https://api.github.com/users/ceridwen/followers","following_url":"https://api.github.com/users/ceridwen/following{/other_user}","gists_url":"https://api.github.com/users/ceridwen/gists{/gist_id}","starred_url":"https://api.github.com/users/ceridwen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceridwen/subscriptions","organizations_url":"https://api.github.com/users/ceridwen/orgs","repos_url":"https://api.github.com/users/ceridwen/repos","events_url":"https://api.github.com/users/ceridwen/events{/privacy}","received_events_url":"https://api.github.com/users/ceridwen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-22T17:28:31Z","updated_at":"2015-09-29T01:04:47Z","closed_at":null,"body":"I'm trying to mimic Python 3's keyword-only arguments in Python 2 with a decorator.  The general pattern is,\r\n\r\n```python\r\ndef decorator_factory(kwonly_args):\r\n    def decorator(function):\r\n        inspect.getargspec(function)\r\n        # do some calculations based on the argspec\r\n        def wrapper(*args, **kws):\r\n            # do more stuff with the previous results and args, kws\r\n            return function(*new_args, **new_kws)\r\n        return wrapper\r\n    return decorator\r\n```\r\n\r\n The full code is at https://code.activestate.com/recipes/578993-keyword-only-arguments-in-python-2x/.\r\n\r\nWith wrapt.decorator the receiving function gets the wrapped function and its arguments at the same time, which would mean redoing the work with inspect.getargspec and its sequents with every call.  If there's a way to prevent that from happening, I don't see it.  Is there a way I'm not seeing?  If not, would you. consider changing the API to make it possible? "},"comment":{"url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/comments/143914883","html_url":"https://github.com/GrahamDumpleton/wrapt/issues/50#issuecomment-143914883","issue_url":"https://api.github.com/repos/GrahamDumpleton/wrapt/issues/50","id":143914883,"user":{"login":"GrahamDumpleton","id":507637,"avatar_url":"https://avatars.githubusercontent.com/u/507637?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamDumpleton","html_url":"https://github.com/GrahamDumpleton","followers_url":"https://api.github.com/users/GrahamDumpleton/followers","following_url":"https://api.github.com/users/GrahamDumpleton/following{/other_user}","gists_url":"https://api.github.com/users/GrahamDumpleton/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamDumpleton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamDumpleton/subscriptions","organizations_url":"https://api.github.com/users/GrahamDumpleton/orgs","repos_url":"https://api.github.com/users/GrahamDumpleton/repos","events_url":"https://api.github.com/users/GrahamDumpleton/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamDumpleton/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T01:04:47Z","updated_at":"2015-09-29T01:04:47Z","body":"FWIW. After looking at the original linked recipe am not sure I like the interface it provides. I don't see the sense in requiring all key word arguments to be listed. Why not just require that the name of the first key word only argument be passed. All the others can be calculated from knowing just it.\r\n\r\nThe test cases also look a bit dodgy in as much as far as I know the key word only argument syntax when used in Python 3 doesn't allow use of ``*args`` for the same function. So it seems this provides functionality over and above what Python 3 syntax would, making it harder to port code to the Python 3 native way later on if that were relied upon.\r\n\r\n"}}