{"action":"created","issue":{"url":"https://api.github.com/repos/scopatz/xonsh/issues/429","labels_url":"https://api.github.com/repos/scopatz/xonsh/issues/429/labels{/name}","comments_url":"https://api.github.com/repos/scopatz/xonsh/issues/429/comments","events_url":"https://api.github.com/repos/scopatz/xonsh/issues/429/events","html_url":"https://github.com/scopatz/xonsh/issues/429","id":112443822,"number":429,"title":"[Feature Request] Xonsh as a decorator","user":{"login":"traverseda","id":2125828,"avatar_url":"https://avatars.githubusercontent.com/u/2125828?v=3","gravatar_id":"","url":"https://api.github.com/users/traverseda","html_url":"https://github.com/traverseda","followers_url":"https://api.github.com/users/traverseda/followers","following_url":"https://api.github.com/users/traverseda/following{/other_user}","gists_url":"https://api.github.com/users/traverseda/gists{/gist_id}","starred_url":"https://api.github.com/users/traverseda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/traverseda/subscriptions","organizations_url":"https://api.github.com/users/traverseda/orgs","repos_url":"https://api.github.com/users/traverseda/repos","events_url":"https://api.github.com/users/traverseda/events{/privacy}","received_events_url":"https://api.github.com/users/traverseda/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/scopatz/xonsh/labels/feature","name":"feature","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/scopatz/xonsh/milestones/2","html_url":"https://github.com/scopatz/xonsh/milestones/v0.3","labels_url":"https://api.github.com/repos/scopatz/xonsh/milestones/2/labels","id":1302567,"number":2,"title":"v0.3","description":"","creator":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"open_issues":58,"closed_issues":31,"state":"open","created_at":"2015-09-12T18:28:59Z","updated_at":"2015-10-20T20:49:07Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-10-20T19:34:53Z","updated_at":"2015-10-20T20:57:02Z","closed_at":null,"body":"I'd like to be able to decorate a function and have it run via xonsh. Not sure how to even approach such a thing, it's too complicated for me.\r\n\r\nI could probably hack *something* together using multiprocessing, but ideally it wouldn't serialize/deserialize the data for every call. Anyone have any idea how to do this?"},"comment":{"url":"https://api.github.com/repos/scopatz/xonsh/issues/comments/149700329","html_url":"https://github.com/scopatz/xonsh/issues/429#issuecomment-149700329","issue_url":"https://api.github.com/repos/scopatz/xonsh/issues/429","id":149700329,"user":{"login":"scopatz","id":320553,"avatar_url":"https://avatars.githubusercontent.com/u/320553?v=3","gravatar_id":"","url":"https://api.github.com/users/scopatz","html_url":"https://github.com/scopatz","followers_url":"https://api.github.com/users/scopatz/followers","following_url":"https://api.github.com/users/scopatz/following{/other_user}","gists_url":"https://api.github.com/users/scopatz/gists{/gist_id}","starred_url":"https://api.github.com/users/scopatz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scopatz/subscriptions","organizations_url":"https://api.github.com/users/scopatz/orgs","repos_url":"https://api.github.com/users/scopatz/repos","events_url":"https://api.github.com/users/scopatz/events{/privacy}","received_events_url":"https://api.github.com/users/scopatz/received_events","type":"User","site_admin":false},"created_at":"2015-10-20T20:57:02Z","updated_at":"2015-10-20T20:57:02Z","body":"Hi @traverseda, this is an interesting idea that would probably take a number of ugly hacks to implement.  \r\n\r\nHowever, we already have import hooks so that you can mix xonsh and python files in the same project. See this part of the turtorial: http://xonsh.org/tutorial.html#importing-xonsh-xsh\r\n\r\nSo the easy thing to do would be to write all your xonsh functions in an .xsh file and then import these into the Python file where you want to call them.  Just note that before you import any xonsh files, you have to load the import hook, which you can do easily by sticking the following *somewhere* in your project:\r\n\r\n```python\r\nfrom xonsh import imphooks\r\n```\r\n\r\nI hope this helps."}}