{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/54206169","id":54206169,"diff_hunk":"@@ -68,12 +68,11 @@ function push!(s::IntSet, n::Integer)\n     return s\n end\n \n-function union!(s::IntSet, ns)\n-    for n in ns\n-        push!(s, n)\n-    end\n-    return s\n-end\n+union!(s::AbstractSet, xs) = _union!(s, xs)\n+\n+_union!(s::AbstractSet, xs) = rawunion!(s, xs)","path":"base/intset.jl","position":12,"original_position":12,"commit_id":"44e275c970dfa2c1a9348f26d61dd94f780f9aca","original_commit_id":"44e275c970dfa2c1a9348f26d61dd94f780f9aca","user":{"login":"gajomi","id":244887,"avatar_url":"https://avatars.githubusercontent.com/u/244887?v=3","gravatar_id":"","url":"https://api.github.com/users/gajomi","html_url":"https://github.com/gajomi","followers_url":"https://api.github.com/users/gajomi/followers","following_url":"https://api.github.com/users/gajomi/following{/other_user}","gists_url":"https://api.github.com/users/gajomi/gists{/gist_id}","starred_url":"https://api.github.com/users/gajomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gajomi/subscriptions","organizations_url":"https://api.github.com/users/gajomi/orgs","repos_url":"https://api.github.com/users/gajomi/repos","events_url":"https://api.github.com/users/gajomi/events{/privacy}","received_events_url":"https://api.github.com/users/gajomi/received_events","type":"User","site_admin":false},"body":"`union!` for `Set` types needs a size hint before calling `rawunion!`, whereas in `IntSet` one gets a size hint for every `push!` (as the underlying container size depends on largest value).","created_at":"2016-02-26T05:18:57Z","updated_at":"2016-02-26T05:18:57Z","html_url":"https://github.com/JuliaLang/julia/pull/15009#discussion_r54206169","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/15009","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/54206169"},"html":{"href":"https://github.com/JuliaLang/julia/pull/15009#discussion_r54206169"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/15009"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/15009","id":58834908,"html_url":"https://github.com/JuliaLang/julia/pull/15009","diff_url":"https://github.com/JuliaLang/julia/pull/15009.diff","patch_url":"https://github.com/JuliaLang/julia/pull/15009.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/15009","number":15009,"state":"open","locked":false,"title":"Optimized unique and union! methods","user":{"login":"gajomi","id":244887,"avatar_url":"https://avatars.githubusercontent.com/u/244887?v=3","gravatar_id":"","url":"https://api.github.com/users/gajomi","html_url":"https://github.com/gajomi","followers_url":"https://api.github.com/users/gajomi/followers","following_url":"https://api.github.com/users/gajomi/following{/other_user}","gists_url":"https://api.github.com/users/gajomi/gists{/gist_id}","starred_url":"https://api.github.com/users/gajomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gajomi/subscriptions","organizations_url":"https://api.github.com/users/gajomi/orgs","repos_url":"https://api.github.com/users/gajomi/repos","events_url":"https://api.github.com/users/gajomi/events{/privacy}","received_events_url":"https://api.github.com/users/gajomi/received_events","type":"User","site_admin":false},"body":"This PR implements performance improvements for unique and union! and adds an additional method signature for unique. The basic outline of the different performance issues can be found in #14649. There are four separates commits in the pull request which implement\r\n\r\n1. optimized methods for associative collections\r\n2. optimized methods for collections with \"small\" eltypes, as well as an additional method unique(c,k), which returns at most k unique elements from a collection c. This is used in the implementation of the aforementioned optimizations, but I think is a useful method in its own right and worth exposing to the user.\r\n3. optimized unique method for range types\r\n4. optimized unique and union methods for sparse-like arrays such as Diagonal,Bidiagonal,SparseVector etc.\r\n\r\nEach of these optimizations have different regimes in which performance improvements become apparent. A benchmark that illustrates performance improvements for unique in action can be seen by looking at the diff in this gist: https://gist.github.com/gajomi/0c184160042ddfc329ab/revisions (results similar for union!). Generally speaking, one sees improvements in walltime performance, although there are some minor performance regressions in memory allocation for some methods. \r\n","created_at":"2016-02-10T01:05:46Z","updated_at":"2016-02-26T05:18:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3de1b498e9c6acee2f807e0c65d346a6035d846e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/15009/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/15009/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/15009/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/44e275c970dfa2c1a9348f26d61dd94f780f9aca","head":{"label":"gajomi:moreuniquemethods","ref":"moreuniquemethods","sha":"44e275c970dfa2c1a9348f26d61dd94f780f9aca","user":{"login":"gajomi","id":244887,"avatar_url":"https://avatars.githubusercontent.com/u/244887?v=3","gravatar_id":"","url":"https://api.github.com/users/gajomi","html_url":"https://github.com/gajomi","followers_url":"https://api.github.com/users/gajomi/followers","following_url":"https://api.github.com/users/gajomi/following{/other_user}","gists_url":"https://api.github.com/users/gajomi/gists{/gist_id}","starred_url":"https://api.github.com/users/gajomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gajomi/subscriptions","organizations_url":"https://api.github.com/users/gajomi/orgs","repos_url":"https://api.github.com/users/gajomi/repos","events_url":"https://api.github.com/users/gajomi/events{/privacy}","received_events_url":"https://api.github.com/users/gajomi/received_events","type":"User","site_admin":false},"repo":{"id":44771345,"name":"julia","full_name":"gajomi/julia","owner":{"login":"gajomi","id":244887,"avatar_url":"https://avatars.githubusercontent.com/u/244887?v=3","gravatar_id":"","url":"https://api.github.com/users/gajomi","html_url":"https://github.com/gajomi","followers_url":"https://api.github.com/users/gajomi/followers","following_url":"https://api.github.com/users/gajomi/following{/other_user}","gists_url":"https://api.github.com/users/gajomi/gists{/gist_id}","starred_url":"https://api.github.com/users/gajomi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gajomi/subscriptions","organizations_url":"https://api.github.com/users/gajomi/orgs","repos_url":"https://api.github.com/users/gajomi/repos","events_url":"https://api.github.com/users/gajomi/events{/privacy}","received_events_url":"https://api.github.com/users/gajomi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/gajomi/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/gajomi/julia","forks_url":"https://api.github.com/repos/gajomi/julia/forks","keys_url":"https://api.github.com/repos/gajomi/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gajomi/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gajomi/julia/teams","hooks_url":"https://api.github.com/repos/gajomi/julia/hooks","issue_events_url":"https://api.github.com/repos/gajomi/julia/issues/events{/number}","events_url":"https://api.github.com/repos/gajomi/julia/events","assignees_url":"https://api.github.com/repos/gajomi/julia/assignees{/user}","branches_url":"https://api.github.com/repos/gajomi/julia/branches{/branch}","tags_url":"https://api.github.com/repos/gajomi/julia/tags","blobs_url":"https://api.github.com/repos/gajomi/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gajomi/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gajomi/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/gajomi/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gajomi/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/gajomi/julia/languages","stargazers_url":"https://api.github.com/repos/gajomi/julia/stargazers","contributors_url":"https://api.github.com/repos/gajomi/julia/contributors","subscribers_url":"https://api.github.com/repos/gajomi/julia/subscribers","subscription_url":"https://api.github.com/repos/gajomi/julia/subscription","commits_url":"https://api.github.com/repos/gajomi/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/gajomi/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/gajomi/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/gajomi/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/gajomi/julia/contents/{+path}","compare_url":"https://api.github.com/repos/gajomi/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gajomi/julia/merges","archive_url":"https://api.github.com/repos/gajomi/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gajomi/julia/downloads","issues_url":"https://api.github.com/repos/gajomi/julia/issues{/number}","pulls_url":"https://api.github.com/repos/gajomi/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/gajomi/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/gajomi/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gajomi/julia/labels{/name}","releases_url":"https://api.github.com/repos/gajomi/julia/releases{/id}","deployments_url":"https://api.github.com/repos/gajomi/julia/deployments","created_at":"2015-10-22T20:27:11Z","updated_at":"2015-10-22T20:27:26Z","pushed_at":"2016-02-24T18:16:03Z","git_url":"git://github.com/gajomi/julia.git","ssh_url":"git@github.com:gajomi/julia.git","clone_url":"https://github.com/gajomi/julia.git","svn_url":"https://github.com/gajomi/julia","homepage":"http://julialang.org/","size":98439,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"bd7adbf247cc9436761ff7e4727378e64362b63b","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-02-25T21:52:48Z","pushed_at":"2016-02-26T05:14:35Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":123436,"stargazers_count":6771,"watchers_count":6771,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1540,"mirror_url":null,"open_issues_count":1679,"forks":1540,"open_issues":1679,"watchers":6771,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/15009"},"html":{"href":"https://github.com/JuliaLang/julia/pull/15009"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/15009"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/15009/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/15009/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/15009/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/44e275c970dfa2c1a9348f26d61dd94f780f9aca"}}}}