{"action":"opened","number":123,"pull_request":{"url":"https://api.github.com/repos/ioam/param/pulls/123","id":65561493,"html_url":"https://github.com/ioam/param/pull/123","diff_url":"https://github.com/ioam/param/pull/123.diff","patch_url":"https://github.com/ioam/param/pull/123.patch","issue_url":"https://api.github.com/repos/ioam/param/issues/123","number":123,"state":"open","locked":false,"title":"Add shared parameter context manager","user":{"login":"philippjfr","id":1550771,"avatar_url":"https://avatars.githubusercontent.com/u/1550771?v=3","gravatar_id":"","url":"https://api.github.com/users/philippjfr","html_url":"https://github.com/philippjfr","followers_url":"https://api.github.com/users/philippjfr/followers","following_url":"https://api.github.com/users/philippjfr/following{/other_user}","gists_url":"https://api.github.com/users/philippjfr/gists{/gist_id}","starred_url":"https://api.github.com/users/philippjfr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philippjfr/subscriptions","organizations_url":"https://api.github.com/users/philippjfr/orgs","repos_url":"https://api.github.com/users/philippjfr/repos","events_url":"https://api.github.com/users/philippjfr/events{/privacy}","received_events_url":"https://api.github.com/users/philippjfr/received_events","type":"User","site_admin":false},"body":"This PR adds the ``shared_parameters`` context manager. Here's the docstring, which should explain what it does:\r\n\r\nContext manager to share parameter instances when creating\r\nmultiple Parameterized objects of the same type. Parameter default\r\nvalues are instantiated once and cached to be reused when another\r\nParameterized object of the same type is instantiated.\r\nCan be useful to easily modify large collections of Parameterized\r\nobjects at once and can provide a significant speedup.\r\n\r\nI've done some basic profiling and this can be a significant boost when instantiating a lot of complex objects.\r\n\r\n```python\r\n%%timeit\r\nwith param.parameterized.shared_parameters():\r\n    hmap = hv.HoloMap({i: hv.Image(np.random.rand(10,10)) for i in range(10000)})\r\n```\r\n\r\n```\r\n1 loop, best of 3: 1.77 s per loop\r\n```\r\n\r\nvs.\r\n\r\n```python\r\n%%timeit\r\nhv.HoloMap({i: hv.Image(np.random.rand(10,10)) for i in range(10000)})\r\n```\r\n\r\n```\r\n1 loop, best of 3: 3.86 s per loop\r\n```\r\n\r\nThere's many cases where this might be useful, particularly holoviews where many operations create a lot of identical objects (e.g. groupby). Sharing a parameter value can also be useful in it's own right since you could change the dimensions of all the elements at once:\r\n\r\n```\r\nwith param.shared_parameters():\r\n    hmap = hv.HoloMap({i: hv.Image(np.random.rand(10,10)) for i in range(10000)})\r\nhmap.last.kdims[:] = [hv.Dimension('A'), hv.Dimension('B')]\r\n```","created_at":"2016-04-07T01:28:40Z","updated_at":"2016-04-07T01:28:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ioam/param/pulls/123/commits","review_comments_url":"https://api.github.com/repos/ioam/param/pulls/123/comments","review_comment_url":"https://api.github.com/repos/ioam/param/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ioam/param/issues/123/comments","statuses_url":"https://api.github.com/repos/ioam/param/statuses/e2a035677df7720b2753c17484e6ba0f7fbd90c1","head":{"label":"ioam:shared_parameters","ref":"shared_parameters","sha":"e2a035677df7720b2753c17484e6ba0f7fbd90c1","user":{"login":"ioam","id":1693676,"avatar_url":"https://avatars.githubusercontent.com/u/1693676?v=3","gravatar_id":"","url":"https://api.github.com/users/ioam","html_url":"https://github.com/ioam","followers_url":"https://api.github.com/users/ioam/followers","following_url":"https://api.github.com/users/ioam/following{/other_user}","gists_url":"https://api.github.com/users/ioam/gists{/gist_id}","starred_url":"https://api.github.com/users/ioam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioam/subscriptions","organizations_url":"https://api.github.com/users/ioam/orgs","repos_url":"https://api.github.com/users/ioam/repos","events_url":"https://api.github.com/users/ioam/events{/privacy}","received_events_url":"https://api.github.com/users/ioam/received_events","type":"Organization","site_admin":false},"repo":{"id":4191817,"name":"param","full_name":"ioam/param","owner":{"login":"ioam","id":1693676,"avatar_url":"https://avatars.githubusercontent.com/u/1693676?v=3","gravatar_id":"","url":"https://api.github.com/users/ioam","html_url":"https://github.com/ioam","followers_url":"https://api.github.com/users/ioam/followers","following_url":"https://api.github.com/users/ioam/following{/other_user}","gists_url":"https://api.github.com/users/ioam/gists{/gist_id}","starred_url":"https://api.github.com/users/ioam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioam/subscriptions","organizations_url":"https://api.github.com/users/ioam/orgs","repos_url":"https://api.github.com/users/ioam/repos","events_url":"https://api.github.com/users/ioam/events{/privacy}","received_events_url":"https://api.github.com/users/ioam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ioam/param","description":"Param: Make your Python code clearer and more reliable by declaring Parameters","fork":false,"url":"https://api.github.com/repos/ioam/param","forks_url":"https://api.github.com/repos/ioam/param/forks","keys_url":"https://api.github.com/repos/ioam/param/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ioam/param/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ioam/param/teams","hooks_url":"https://api.github.com/repos/ioam/param/hooks","issue_events_url":"https://api.github.com/repos/ioam/param/issues/events{/number}","events_url":"https://api.github.com/repos/ioam/param/events","assignees_url":"https://api.github.com/repos/ioam/param/assignees{/user}","branches_url":"https://api.github.com/repos/ioam/param/branches{/branch}","tags_url":"https://api.github.com/repos/ioam/param/tags","blobs_url":"https://api.github.com/repos/ioam/param/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ioam/param/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ioam/param/git/refs{/sha}","trees_url":"https://api.github.com/repos/ioam/param/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ioam/param/statuses/{sha}","languages_url":"https://api.github.com/repos/ioam/param/languages","stargazers_url":"https://api.github.com/repos/ioam/param/stargazers","contributors_url":"https://api.github.com/repos/ioam/param/contributors","subscribers_url":"https://api.github.com/repos/ioam/param/subscribers","subscription_url":"https://api.github.com/repos/ioam/param/subscription","commits_url":"https://api.github.com/repos/ioam/param/commits{/sha}","git_commits_url":"https://api.github.com/repos/ioam/param/git/commits{/sha}","comments_url":"https://api.github.com/repos/ioam/param/comments{/number}","issue_comment_url":"https://api.github.com/repos/ioam/param/issues/comments{/number}","contents_url":"https://api.github.com/repos/ioam/param/contents/{+path}","compare_url":"https://api.github.com/repos/ioam/param/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ioam/param/merges","archive_url":"https://api.github.com/repos/ioam/param/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ioam/param/downloads","issues_url":"https://api.github.com/repos/ioam/param/issues{/number}","pulls_url":"https://api.github.com/repos/ioam/param/pulls{/number}","milestones_url":"https://api.github.com/repos/ioam/param/milestones{/number}","notifications_url":"https://api.github.com/repos/ioam/param/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ioam/param/labels{/name}","releases_url":"https://api.github.com/repos/ioam/param/releases{/id}","deployments_url":"https://api.github.com/repos/ioam/param/deployments","created_at":"2012-05-01T11:51:08Z","updated_at":"2016-02-05T07:05:58Z","pushed_at":"2016-04-07T01:16:39Z","git_url":"git://github.com/ioam/param.git","ssh_url":"git@github.com:ioam/param.git","clone_url":"https://github.com/ioam/param.git","svn_url":"https://github.com/ioam/param","homepage":"http://ioam.github.com/param/","size":2985,"stargazers_count":49,"watchers_count":49,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":53,"forks":9,"open_issues":53,"watchers":49,"default_branch":"master"}},"base":{"label":"ioam:master","ref":"master","sha":"1f94abcc3855d449504ff899fdddc622a5362e52","user":{"login":"ioam","id":1693676,"avatar_url":"https://avatars.githubusercontent.com/u/1693676?v=3","gravatar_id":"","url":"https://api.github.com/users/ioam","html_url":"https://github.com/ioam","followers_url":"https://api.github.com/users/ioam/followers","following_url":"https://api.github.com/users/ioam/following{/other_user}","gists_url":"https://api.github.com/users/ioam/gists{/gist_id}","starred_url":"https://api.github.com/users/ioam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioam/subscriptions","organizations_url":"https://api.github.com/users/ioam/orgs","repos_url":"https://api.github.com/users/ioam/repos","events_url":"https://api.github.com/users/ioam/events{/privacy}","received_events_url":"https://api.github.com/users/ioam/received_events","type":"Organization","site_admin":false},"repo":{"id":4191817,"name":"param","full_name":"ioam/param","owner":{"login":"ioam","id":1693676,"avatar_url":"https://avatars.githubusercontent.com/u/1693676?v=3","gravatar_id":"","url":"https://api.github.com/users/ioam","html_url":"https://github.com/ioam","followers_url":"https://api.github.com/users/ioam/followers","following_url":"https://api.github.com/users/ioam/following{/other_user}","gists_url":"https://api.github.com/users/ioam/gists{/gist_id}","starred_url":"https://api.github.com/users/ioam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ioam/subscriptions","organizations_url":"https://api.github.com/users/ioam/orgs","repos_url":"https://api.github.com/users/ioam/repos","events_url":"https://api.github.com/users/ioam/events{/privacy}","received_events_url":"https://api.github.com/users/ioam/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ioam/param","description":"Param: Make your Python code clearer and more reliable by declaring Parameters","fork":false,"url":"https://api.github.com/repos/ioam/param","forks_url":"https://api.github.com/repos/ioam/param/forks","keys_url":"https://api.github.com/repos/ioam/param/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ioam/param/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ioam/param/teams","hooks_url":"https://api.github.com/repos/ioam/param/hooks","issue_events_url":"https://api.github.com/repos/ioam/param/issues/events{/number}","events_url":"https://api.github.com/repos/ioam/param/events","assignees_url":"https://api.github.com/repos/ioam/param/assignees{/user}","branches_url":"https://api.github.com/repos/ioam/param/branches{/branch}","tags_url":"https://api.github.com/repos/ioam/param/tags","blobs_url":"https://api.github.com/repos/ioam/param/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ioam/param/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ioam/param/git/refs{/sha}","trees_url":"https://api.github.com/repos/ioam/param/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ioam/param/statuses/{sha}","languages_url":"https://api.github.com/repos/ioam/param/languages","stargazers_url":"https://api.github.com/repos/ioam/param/stargazers","contributors_url":"https://api.github.com/repos/ioam/param/contributors","subscribers_url":"https://api.github.com/repos/ioam/param/subscribers","subscription_url":"https://api.github.com/repos/ioam/param/subscription","commits_url":"https://api.github.com/repos/ioam/param/commits{/sha}","git_commits_url":"https://api.github.com/repos/ioam/param/git/commits{/sha}","comments_url":"https://api.github.com/repos/ioam/param/comments{/number}","issue_comment_url":"https://api.github.com/repos/ioam/param/issues/comments{/number}","contents_url":"https://api.github.com/repos/ioam/param/contents/{+path}","compare_url":"https://api.github.com/repos/ioam/param/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ioam/param/merges","archive_url":"https://api.github.com/repos/ioam/param/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ioam/param/downloads","issues_url":"https://api.github.com/repos/ioam/param/issues{/number}","pulls_url":"https://api.github.com/repos/ioam/param/pulls{/number}","milestones_url":"https://api.github.com/repos/ioam/param/milestones{/number}","notifications_url":"https://api.github.com/repos/ioam/param/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ioam/param/labels{/name}","releases_url":"https://api.github.com/repos/ioam/param/releases{/id}","deployments_url":"https://api.github.com/repos/ioam/param/deployments","created_at":"2012-05-01T11:51:08Z","updated_at":"2016-02-05T07:05:58Z","pushed_at":"2016-04-07T01:16:39Z","git_url":"git://github.com/ioam/param.git","ssh_url":"git@github.com:ioam/param.git","clone_url":"https://github.com/ioam/param.git","svn_url":"https://github.com/ioam/param","homepage":"http://ioam.github.com/param/","size":2985,"stargazers_count":49,"watchers_count":49,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":9,"mirror_url":null,"open_issues_count":53,"forks":9,"open_issues":53,"watchers":49,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ioam/param/pulls/123"},"html":{"href":"https://github.com/ioam/param/pull/123"},"issue":{"href":"https://api.github.com/repos/ioam/param/issues/123"},"comments":{"href":"https://api.github.com/repos/ioam/param/issues/123/comments"},"review_comments":{"href":"https://api.github.com/repos/ioam/param/pulls/123/comments"},"review_comment":{"href":"https://api.github.com/repos/ioam/param/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ioam/param/pulls/123/commits"},"statuses":{"href":"https://api.github.com/repos/ioam/param/statuses/e2a035677df7720b2753c17484e6ba0f7fbd90c1"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":52,"deletions":2,"changed_files":3}}