{"action":"closed","number":8309,"pull_request":{"url":"https://api.github.com/repos/bokeh/bokeh/pulls/8309","id":220838405,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwODM4NDA1","html_url":"https://github.com/bokeh/bokeh/pull/8309","diff_url":"https://github.com/bokeh/bokeh/pull/8309.diff","patch_url":"https://github.com/bokeh/bokeh/pull/8309.patch","issue_url":"https://api.github.com/repos/bokeh/bokeh/issues/8309","number":8309,"state":"closed","locked":false,"title":"Bryanv/reduce import code","user":{"login":"bryevdv","id":1078448,"node_id":"MDQ6VXNlcjEwNzg0NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1078448?v=4","gravatar_id":"","url":"https://api.github.com/users/bryevdv","html_url":"https://github.com/bryevdv","followers_url":"https://api.github.com/users/bryevdv/followers","following_url":"https://api.github.com/users/bryevdv/following{/other_user}","gists_url":"https://api.github.com/users/bryevdv/gists{/gist_id}","starred_url":"https://api.github.com/users/bryevdv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryevdv/subscriptions","organizations_url":"https://api.github.com/users/bryevdv/orgs","repos_url":"https://api.github.com/users/bryevdv/repos","events_url":"https://api.github.com/users/bryevdv/events{/privacy}","received_events_url":"https://api.github.com/users/bryevdv/received_events","type":"User","site_admin":false},"body":"This PR claims some low hanging fruit for reducing Bokeh import times:\r\n\r\n* Don't use `PackageLoader` for loading Bokeh Jinja templates (required `pkg_resources` import is very expensive)\r\n\r\n* defer non-stdlib imports in sampledata modules (downloading sampledata is rare usage)\r\n\r\n* reduce some dynamic docstring manipulations\r\n\r\nAll told this shaves ~200ms off `import bokeh.plotting` on my laptop. The results using:\r\n```\r\npython3.7 -X importtime -c \"import bokeh.plotting\" 2> bokeh3.log\r\ntuna bokeh3.log\r\n``` \r\nare:\r\n\r\n<img width=\"1238\" alt=\"screen shot 2018-10-05 at 15 16 30\" src=\"https://user-images.githubusercontent.com/1078448/46562596-a94d9280-c8b1-11e8-9062-d80670a12813.png\">\r\n\r\nAbout half of that ~600ms appears to be NumPy and Pandas, which is borne out by this very rough timing:\r\n\r\n```\r\nIn [1]: import pandas, numpy\r\n\r\nIn [2]:\r\n\r\nIn [2]: %time import bokeh.plotting\r\nCPU times: user 190 ms, sys: 40.8 ms, total: 231 ms\r\nWall time: 309 ms\r\n```\r\n\r\nIt's worth noting that 60-70 ms for computing `bokeh.__version__` disappears in real release packages where the version string is hardcoded. \r\n\r\nWe can't do much about the NumPy/Pandas burden, but there are still some things we can do to reduce things on our end later:\r\n\r\n* defer loading default temlate yaml files until requested (this will take a little more work/care)\r\n* remove more dynamic module code (e.g dynamic glyph method construction)\r\n* defer loading Jinja templates until needed\r\n* move submodules of `bokeh.models` to `bokeh._modules` so that individual models can be imported internally without importing everything in `bokeh.models.__init__.py`\r\n\r\nI would estimate ~150ms (relative reference on this laptop) is probably a floor for `import bokeh.plotting`","created_at":"2018-10-05T22:21:40Z","updated_at":"2018-10-05T23:42:48Z","closed_at":"2018-10-05T23:42:48Z","merged_at":"2018-10-05T23:42:48Z","merge_commit_sha":"be0ae3e15923555d4b853a45e524dec374689f60","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":123811465,"node_id":"MDU6TGFiZWwxMjM4MTE0NjU=","url":"https://api.github.com/repos/bokeh/bokeh/labels/reso:%20completed","name":"reso: completed","color":"345065","default":false},{"id":88740530,"node_id":"MDU6TGFiZWw4ODc0MDUzMA==","url":"https://api.github.com/repos/bokeh/bokeh/labels/status:%20accepted","name":"status: accepted","color":"bfe5bf","default":false},{"id":106468141,"node_id":"MDU6TGFiZWwxMDY0NjgxNDE=","url":"https://api.github.com/repos/bokeh/bokeh/labels/type:%20task","name":"type: task","color":"872A50","default":false}],"milestone":{"url":"https://api.github.com/repos/bokeh/bokeh/milestones/43","html_url":"https://github.com/bokeh/bokeh/milestone/43","labels_url":"https://api.github.com/repos/bokeh/bokeh/milestones/43/labels","id":3343866,"node_id":"MDk6TWlsZXN0b25lMzM0Mzg2Ng==","number":43,"title":"1.0","description":"","creator":{"login":"mattpap","id":27475,"node_id":"MDQ6VXNlcjI3NDc1","avatar_url":"https://avatars2.githubusercontent.com/u/27475?v=4","gravatar_id":"","url":"https://api.github.com/users/mattpap","html_url":"https://github.com/mattpap","followers_url":"https://api.github.com/users/mattpap/followers","following_url":"https://api.github.com/users/mattpap/following{/other_user}","gists_url":"https://api.github.com/users/mattpap/gists{/gist_id}","starred_url":"https://api.github.com/users/mattpap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mattpap/subscriptions","organizations_url":"https://api.github.com/users/mattpap/orgs","repos_url":"https://api.github.com/users/mattpap/repos","events_url":"https://api.github.com/users/mattpap/events{/privacy}","received_events_url":"https://api.github.com/users/mattpap/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":115,"state":"open","created_at":"2018-05-14T10:17:24Z","updated_at":"2018-10-05T23:42:48Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/bokeh/bokeh/pulls/8309/commits","review_comments_url":"https://api.github.com/repos/bokeh/bokeh/pulls/8309/comments","review_comment_url":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bokeh/bokeh/issues/8309/comments","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/2fcc3179e40780c69499efcf303854a666efbfdf","head":{"label":"bokeh:bryanv/reduce_import_code","ref":"bryanv/reduce_import_code","sha":"2fcc3179e40780c69499efcf303854a666efbfdf","user":{"login":"bokeh","id":8440965,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0NDA5NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/8440965?v=4","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"node_id":"MDEwOlJlcG9zaXRvcnkzODM0MzMy","name":"bokeh","full_name":"bokeh/bokeh","private":false,"owner":{"login":"bokeh","id":8440965,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0NDA5NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/8440965?v=4","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","deployments_url":"https://api.github.com/repos/bokeh/bokeh/deployments","created_at":"2012-03-26T15:40:01Z","updated_at":"2018-10-05T14:40:26Z","pushed_at":"2018-10-05T23:42:48Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":145774,"stargazers_count":8225,"watchers_count":8225,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2195,"mirror_url":null,"archived":false,"open_issues_count":434,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":2195,"open_issues":434,"watchers":8225,"default_branch":"master"}},"base":{"label":"bokeh:master","ref":"master","sha":"7abd5436102d2d4621905ca1fd96a5968add3f56","user":{"login":"bokeh","id":8440965,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0NDA5NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/8440965?v=4","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"repo":{"id":3834332,"node_id":"MDEwOlJlcG9zaXRvcnkzODM0MzMy","name":"bokeh","full_name":"bokeh/bokeh","private":false,"owner":{"login":"bokeh","id":8440965,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg0NDA5NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/8440965?v=4","gravatar_id":"","url":"https://api.github.com/users/bokeh","html_url":"https://github.com/bokeh","followers_url":"https://api.github.com/users/bokeh/followers","following_url":"https://api.github.com/users/bokeh/following{/other_user}","gists_url":"https://api.github.com/users/bokeh/gists{/gist_id}","starred_url":"https://api.github.com/users/bokeh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bokeh/subscriptions","organizations_url":"https://api.github.com/users/bokeh/orgs","repos_url":"https://api.github.com/users/bokeh/repos","events_url":"https://api.github.com/users/bokeh/events{/privacy}","received_events_url":"https://api.github.com/users/bokeh/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/bokeh/bokeh","description":"Interactive Web Plotting for Python","fork":false,"url":"https://api.github.com/repos/bokeh/bokeh","forks_url":"https://api.github.com/repos/bokeh/bokeh/forks","keys_url":"https://api.github.com/repos/bokeh/bokeh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bokeh/bokeh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bokeh/bokeh/teams","hooks_url":"https://api.github.com/repos/bokeh/bokeh/hooks","issue_events_url":"https://api.github.com/repos/bokeh/bokeh/issues/events{/number}","events_url":"https://api.github.com/repos/bokeh/bokeh/events","assignees_url":"https://api.github.com/repos/bokeh/bokeh/assignees{/user}","branches_url":"https://api.github.com/repos/bokeh/bokeh/branches{/branch}","tags_url":"https://api.github.com/repos/bokeh/bokeh/tags","blobs_url":"https://api.github.com/repos/bokeh/bokeh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bokeh/bokeh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bokeh/bokeh/git/refs{/sha}","trees_url":"https://api.github.com/repos/bokeh/bokeh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bokeh/bokeh/statuses/{sha}","languages_url":"https://api.github.com/repos/bokeh/bokeh/languages","stargazers_url":"https://api.github.com/repos/bokeh/bokeh/stargazers","contributors_url":"https://api.github.com/repos/bokeh/bokeh/contributors","subscribers_url":"https://api.github.com/repos/bokeh/bokeh/subscribers","subscription_url":"https://api.github.com/repos/bokeh/bokeh/subscription","commits_url":"https://api.github.com/repos/bokeh/bokeh/commits{/sha}","git_commits_url":"https://api.github.com/repos/bokeh/bokeh/git/commits{/sha}","comments_url":"https://api.github.com/repos/bokeh/bokeh/comments{/number}","issue_comment_url":"https://api.github.com/repos/bokeh/bokeh/issues/comments{/number}","contents_url":"https://api.github.com/repos/bokeh/bokeh/contents/{+path}","compare_url":"https://api.github.com/repos/bokeh/bokeh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bokeh/bokeh/merges","archive_url":"https://api.github.com/repos/bokeh/bokeh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bokeh/bokeh/downloads","issues_url":"https://api.github.com/repos/bokeh/bokeh/issues{/number}","pulls_url":"https://api.github.com/repos/bokeh/bokeh/pulls{/number}","milestones_url":"https://api.github.com/repos/bokeh/bokeh/milestones{/number}","notifications_url":"https://api.github.com/repos/bokeh/bokeh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bokeh/bokeh/labels{/name}","releases_url":"https://api.github.com/repos/bokeh/bokeh/releases{/id}","deployments_url":"https://api.github.com/repos/bokeh/bokeh/deployments","created_at":"2012-03-26T15:40:01Z","updated_at":"2018-10-05T14:40:26Z","pushed_at":"2018-10-05T23:42:48Z","git_url":"git://github.com/bokeh/bokeh.git","ssh_url":"git@github.com:bokeh/bokeh.git","clone_url":"https://github.com/bokeh/bokeh.git","svn_url":"https://github.com/bokeh/bokeh","homepage":"http://bokeh.pydata.org/en/latest/","size":145774,"stargazers_count":8225,"watchers_count":8225,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2195,"mirror_url":null,"archived":false,"open_issues_count":434,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":2195,"open_issues":434,"watchers":8225,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/8309"},"html":{"href":"https://github.com/bokeh/bokeh/pull/8309"},"issue":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/8309"},"comments":{"href":"https://api.github.com/repos/bokeh/bokeh/issues/8309/comments"},"review_comments":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/8309/comments"},"review_comment":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bokeh/bokeh/pulls/8309/commits"},"statuses":{"href":"https://api.github.com/repos/bokeh/bokeh/statuses/2fcc3179e40780c69499efcf303854a666efbfdf"}},"author_association":"MEMBER","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"bryevdv","id":1078448,"node_id":"MDQ6VXNlcjEwNzg0NDg=","avatar_url":"https://avatars3.githubusercontent.com/u/1078448?v=4","gravatar_id":"","url":"https://api.github.com/users/bryevdv","html_url":"https://github.com/bryevdv","followers_url":"https://api.github.com/users/bryevdv/followers","following_url":"https://api.github.com/users/bryevdv/following{/other_user}","gists_url":"https://api.github.com/users/bryevdv/gists{/gist_id}","starred_url":"https://api.github.com/users/bryevdv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryevdv/subscriptions","organizations_url":"https://api.github.com/users/bryevdv/orgs","repos_url":"https://api.github.com/users/bryevdv/repos","events_url":"https://api.github.com/users/bryevdv/events{/privacy}","received_events_url":"https://api.github.com/users/bryevdv/received_events","type":"User","site_admin":false},"comments":4,"review_comments":0,"maintainer_can_modify":false,"commits":3,"additions":66,"deletions":50,"changed_files":3}}
{"actor":{"display_login":"bryevdv"}}