{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/5275","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/5275/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/5275/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/5275/events","html_url":"https://github.com/astropy/astropy/pull/5275","id":173662012,"number":5275,"title":"make docstring-update optional for io.registry and some additional performance changes","user":{"login":"MSeifert04","id":14200878,"avatar_url":"https://avatars.githubusercontent.com/u/14200878?v=3","gravatar_id":"","url":"https://api.github.com/users/MSeifert04","html_url":"https://github.com/MSeifert04","followers_url":"https://api.github.com/users/MSeifert04/followers","following_url":"https://api.github.com/users/MSeifert04/following{/other_user}","gists_url":"https://api.github.com/users/MSeifert04/gists{/gist_id}","starred_url":"https://api.github.com/users/MSeifert04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSeifert04/subscriptions","organizations_url":"https://api.github.com/users/MSeifert04/orgs","repos_url":"https://api.github.com/users/MSeifert04/repos","events_url":"https://api.github.com/users/MSeifert04/events{/privacy}","received_events_url":"https://api.github.com/users/MSeifert04/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/astropy/astropy/labels/io.registry","name":"io.registry","color":"c7def8"},{"url":"https://api.github.com/repos/astropy/astropy/labels/Performance","name":"Performance","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/astropy/astropy/milestones/38","html_url":"https://github.com/astropy/astropy/milestones/v1.3.0","labels_url":"https://api.github.com/repos/astropy/astropy/milestones/38/labels","id":1761583,"number":38,"title":"v1.3.0","description":"","creator":{"login":"eteq","id":346587,"avatar_url":"https://avatars.githubusercontent.com/u/346587?v=3","gravatar_id":"","url":"https://api.github.com/users/eteq","html_url":"https://github.com/eteq","followers_url":"https://api.github.com/users/eteq/followers","following_url":"https://api.github.com/users/eteq/following{/other_user}","gists_url":"https://api.github.com/users/eteq/gists{/gist_id}","starred_url":"https://api.github.com/users/eteq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eteq/subscriptions","organizations_url":"https://api.github.com/users/eteq/orgs","repos_url":"https://api.github.com/users/eteq/repos","events_url":"https://api.github.com/users/eteq/events{/privacy}","received_events_url":"https://api.github.com/users/eteq/received_events","type":"User","site_admin":false},"open_issues":29,"closed_issues":44,"state":"open","created_at":"2016-05-12T04:39:02Z","updated_at":"2016-09-08T20:50:30Z","due_on":null,"closed_at":null},"comments":17,"created_at":"2016-08-28T19:08:52Z","updated_at":"2016-09-08T22:13:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/astropy/astropy/pulls/5275","html_url":"https://github.com/astropy/astropy/pull/5275","diff_url":"https://github.com/astropy/astropy/pull/5275.diff","patch_url":"https://github.com/astropy/astropy/pull/5275.patch"},"body":"This further (see #5262 for links and rationale) decreases the creation time of the docstring-tables for `read` and `write` functions using the `io.registry`:\r\n\r\n## ``_is_best_match``\r\nThis function was responsible for 10% of the time spent in `get_formats`. The time was \"used\" to create the list of possible classes but this list was only necessary _if_ `class1 is not class2`. This check is now done before creating the list.\r\n\r\nThe second improvement here (maybe it's currently rather a disadvantage) is that instead of creating a list a `set` is created. This (a) speeds up the `not in` comparison, (b) discards duplicates but (c) is slower than creating a list and the `in` operation is also slower because the list only contained 36 `Table`-links (a speedup would only be visible if the list would contain several distinct classes)\r\n\r\nWith these changes the relative time spent in `_is_best_match` was reduced to 3%. This is not really noticable though because other parts take much more time. In effect a call to `register_reader` or `register_writer` is sped up by 2%.\r\n\r\n## ``get_formats`` and ``_update__doc__``\r\n20% of the time spent in `_update__doc__` was because of the line `format_table = format_table[has_readwrite]`. By replacing this with a list comprehension in `get_formats` these 20% were brought down to less than 1%.\r\n\r\nThis change noticably reduced the `import astropy.coordinates` time (and similar subpackages which import Table) by 3-4%\r\n\r\n## Making the ``_update__doc__`` function optional\r\n\r\nAs alternative to #5264 which proposed to create the docstring dynamically this PR includes a change which makes the ``_update__doc__`` function optional. The registration of readers/writers don't force the update anymore (but do it by default for backwards compatibility) and it's disabled for all in-astropy-registrations. However after importing `astropy.table` the docs are created _once_.\r\n\r\n## One additional change\r\n\r\nInstead of doing `lines.extend([' ' * left_indent + line for line in new_lines])` the `' ' * left_indent` is determined before the list-comprehension. This yields an amazing 0.01% speedup.\r\n\r\n## Result\r\n\r\nThe `python -m timeit -n 1 -r 1 \"from astropy.coordinates import SkyCoord\"` command takes 13% less time than before. (At least on my computer :smile:)\r\n\r\n@mhvk Since you proposed the dynamic creation maybe you can judge if this approach would also fix your issue (or if such a change should be avoided)."},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/245758499","html_url":"https://github.com/astropy/astropy/pull/5275#issuecomment-245758499","issue_url":"https://api.github.com/repos/astropy/astropy/issues/5275","id":245758499,"user":{"login":"MSeifert04","id":14200878,"avatar_url":"https://avatars.githubusercontent.com/u/14200878?v=3","gravatar_id":"","url":"https://api.github.com/users/MSeifert04","html_url":"https://github.com/MSeifert04","followers_url":"https://api.github.com/users/MSeifert04/followers","following_url":"https://api.github.com/users/MSeifert04/following{/other_user}","gists_url":"https://api.github.com/users/MSeifert04/gists{/gist_id}","starred_url":"https://api.github.com/users/MSeifert04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MSeifert04/subscriptions","organizations_url":"https://api.github.com/users/MSeifert04/orgs","repos_url":"https://api.github.com/users/MSeifert04/repos","events_url":"https://api.github.com/users/MSeifert04/events{/privacy}","received_events_url":"https://api.github.com/users/MSeifert04/received_events","type":"User","site_admin":false},"created_at":"2016-09-08T22:13:43Z","updated_at":"2016-09-08T22:13:43Z","body":"@taldcroft I've commited the contextmanager."}}
{"actor":{"display_login":"MSeifert04"}}