{"action":"created","issue":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/13814","repository_url":"https://api.github.com/repos/xbmc/xbmc","labels_url":"https://api.github.com/repos/xbmc/xbmc/issues/13814/labels{/name}","comments_url":"https://api.github.com/repos/xbmc/xbmc/issues/13814/comments","events_url":"https://api.github.com/repos/xbmc/xbmc/issues/13814/events","html_url":"https://github.com/xbmc/xbmc/pull/13814","id":317582237,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg0MDAwNDMw","number":13814,"title":"Reusepython","user":{"login":"peak3d","id":22704999,"node_id":"MDQ6VXNlcjIyNzA0OTk5","avatar_url":"https://avatars3.githubusercontent.com/u/22704999?v=4","gravatar_id":"","url":"https://api.github.com/users/peak3d","html_url":"https://github.com/peak3d","followers_url":"https://api.github.com/users/peak3d/followers","following_url":"https://api.github.com/users/peak3d/following{/other_user}","gists_url":"https://api.github.com/users/peak3d/gists{/gist_id}","starred_url":"https://api.github.com/users/peak3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peak3d/subscriptions","organizations_url":"https://api.github.com/users/peak3d/orgs","repos_url":"https://api.github.com/users/peak3d/repos","events_url":"https://api.github.com/users/peak3d/events{/privacy}","received_events_url":"https://api.github.com/users/peak3d/received_events","type":"User","site_admin":false},"labels":[{"id":279663844,"node_id":"MDU6TGFiZWwyNzk2NjM4NDQ=","url":"https://api.github.com/repos/xbmc/xbmc/labels/Python","name":"Python","color":"009800","default":false},{"id":13096702,"node_id":"MDU6TGFiZWwxMzA5NjcwMg==","url":"https://api.github.com/repos/xbmc/xbmc/labels/Wiki-Needed","name":"Wiki-Needed","color":"5319e7","default":false},{"id":400751192,"node_id":"MDU6TGFiZWw0MDA3NTExOTI=","url":"https://api.github.com/repos/xbmc/xbmc/labels/v18%20Leia","name":"v18 Leia","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/xbmc/xbmc/milestones/108","html_url":"https://github.com/xbmc/xbmc/milestone/108","labels_url":"https://api.github.com/repos/xbmc/xbmc/milestones/108/labels","id":3158033,"node_id":"MDk6TWlsZXN0b25lMzE1ODAzMw==","number":108,"title":"Leia 18.0-alpha2","description":"","creator":{"login":"MartijnKaijser","id":907436,"node_id":"MDQ6VXNlcjkwNzQzNg==","avatar_url":"https://avatars1.githubusercontent.com/u/907436?v=4","gravatar_id":"","url":"https://api.github.com/users/MartijnKaijser","html_url":"https://github.com/MartijnKaijser","followers_url":"https://api.github.com/users/MartijnKaijser/followers","following_url":"https://api.github.com/users/MartijnKaijser/following{/other_user}","gists_url":"https://api.github.com/users/MartijnKaijser/gists{/gist_id}","starred_url":"https://api.github.com/users/MartijnKaijser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartijnKaijser/subscriptions","organizations_url":"https://api.github.com/users/MartijnKaijser/orgs","repos_url":"https://api.github.com/users/MartijnKaijser/repos","events_url":"https://api.github.com/users/MartijnKaijser/events{/privacy}","received_events_url":"https://api.github.com/users/MartijnKaijser/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":436,"state":"closed","created_at":"2018-03-03T07:09:50Z","updated_at":"2018-06-21T15:50:05Z","due_on":"2018-06-13T07:00:00Z","closed_at":"2018-06-21T15:50:05Z"},"comments":27,"created_at":"2018-04-25T11:12:02Z","updated_at":"2018-07-02T06:05:29Z","closed_at":"2018-06-12T09:19:01Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/xbmc/xbmc/pulls/13814","html_url":"https://github.com/xbmc/xbmc/pull/13814","diff_url":"https://github.com/xbmc/xbmc/pull/13814.diff","patch_url":"https://github.com/xbmc/xbmc/pull/13814.patch"},"body":"## Description\r\nTry to reuse the last used python thread / interpreter to avoid module reloading\r\n\r\n- If an Python addon is invoked (yes, only addons, no script / no job), the thread (together with its Invoker instance) is saved and kept open.\r\n- If the next python call requests the same addon script, the last saved thread is used instead opening a new thread + interpreter.\r\n- If the user changes the addon, the last saved thread is freed and a new thread / interprter instanciated for the new addon script call.\r\n\r\n## Motivation and Context\r\nLaunching each script call with a new Python interpreter instance takes much time. Reasons are mainly module reloading (own and foreign). Reusing the same Interpreter during navigating inside one addon reduces times significantly. On my test Addon from ~2 sec -> 100ms (per click) on ARM based device (Andoid and Linux)\r\n\r\n## Types of change\r\n- [ ] Bug fix (non-breaking change which fixes an issue)\r\n- [X] Improvement (non-breaking change which improves existing functionality)\r\n- [ ] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Notes\r\nUsing this commit changes behavior for addon developers. because script modules are not reread for every call, you have to switch to another addon and then back to your addon to see your changes made in python code\r\n\r\n----------------------\r\nIf your submodules (all scripts which are not the default script) have global variables where comandline parameters are saved  (e.g. handle=sys.argv[1]), they will remain at their initial value (first call of addon). In order to work as expected, you either have to refresh them (passing from default.py to submodules) or use sys.arg[#] call in your submodules instead the global variable(s).\r\n\r\nThe first 2 parameter (url / pluginhandle) are now persistend over python sessions which are reused.\r\nFor the following parameters (action stuff) above mentioned note must be respected.\r\n\r\n----------------------\r\n\r\nThis feature can be disabled in addon.xml file metadata section\r\n\r\n```\r\n<extension point=\"xbmc.addon.metadata\">\r\n  <reuselanguageinvoker>false</reuselanguageinvoker>\r\n</extension>\r\n```"},"comment":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/comments/401681124","html_url":"https://github.com/xbmc/xbmc/pull/13814#issuecomment-401681124","issue_url":"https://api.github.com/repos/xbmc/xbmc/issues/13814","id":401681124,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTY4MTEyNA==","user":{"login":"peak3d","id":22704999,"node_id":"MDQ6VXNlcjIyNzA0OTk5","avatar_url":"https://avatars3.githubusercontent.com/u/22704999?v=4","gravatar_id":"","url":"https://api.github.com/users/peak3d","html_url":"https://github.com/peak3d","followers_url":"https://api.github.com/users/peak3d/followers","following_url":"https://api.github.com/users/peak3d/following{/other_user}","gists_url":"https://api.github.com/users/peak3d/gists{/gist_id}","starred_url":"https://api.github.com/users/peak3d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peak3d/subscriptions","organizations_url":"https://api.github.com/users/peak3d/orgs","repos_url":"https://api.github.com/users/peak3d/repos","events_url":"https://api.github.com/users/peak3d/events{/privacy}","received_events_url":"https://api.github.com/users/peak3d/received_events","type":"User","site_admin":false},"created_at":"2018-07-02T06:05:29Z","updated_at":"2018-07-02T06:05:29Z","author_association":"CONTRIBUTOR","body":"@Sorien Thanx for pointing to the page,\r\n\r\nIf you have read carefully what I have written in PR and other comments, you may have noticed, that for router script (default.py) nothing has chaged. You can use globals there without any change. This is the reason why most of the scripts still run.\r\n\r\nBut: If you now decide do use submodules (scripts in resources lib), you most probably do this because you want to push performance. What we told users in the past (use submodules to speed up your addon), was not working correctly, but it is with the original PR.\r\nBut you have to simply follow some simple, easy to manage guidelines. This is basically: Use functions in your submodules, or use classes which are instanciated from router.\r\n100% of the python modules are working fine, because they are build up as a lib. Only some koi addons do not work, because they are wrong by basic design.\r\n\r\nLong story short: documentation in your linked article is fine, it does not touch self written submodules.\r\n\r\nSuggestion to all of the ppl. who mislike this PR: Buy a rbpi, install LibreELEC, and play around with your addon. Testing addons on a Intel i7 does not cover kodi userbase."}}
{"actor":{"display_login":"peak3d"}}