{"action":"opened","number":673,"pull_request":{"url":"https://api.github.com/repos/pika/pika/pulls/673","id":52952455,"html_url":"https://github.com/pika/pika/pull/673","diff_url":"https://github.com/pika/pika/pull/673.diff","patch_url":"https://github.com/pika/pika/pull/673.patch","issue_url":"https://api.github.com/repos/pika/pika/issues/673","number":673,"state":"open","locked":false,"title":"Connection._next_channel_number optimization","user":{"login":"eugals","id":479407,"avatar_url":"https://avatars.githubusercontent.com/u/479407?v=3","gravatar_id":"","url":"https://api.github.com/users/eugals","html_url":"https://github.com/eugals","followers_url":"https://api.github.com/users/eugals/followers","following_url":"https://api.github.com/users/eugals/following{/other_user}","gists_url":"https://api.github.com/users/eugals/gists{/gist_id}","starred_url":"https://api.github.com/users/eugals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugals/subscriptions","organizations_url":"https://api.github.com/users/eugals/orgs","repos_url":"https://api.github.com/users/eugals/repos","events_url":"https://api.github.com/users/eugals/events{/privacy}","received_events_url":"https://api.github.com/users/eugals/received_events","type":"User","site_admin":false},"body":"When we have many (hundreds) channels opened within a connection, the current `Connection._next_channel_number` implementation may become a bottleneck sometimes.\r\n```Python\r\n        ckeys = set(self._channels.keys())\r\n        if not ckeys:\r\n            return 1\r\n        return [x + 1 for x in sorted(ckeys) if x + 1 not in ckeys][0]\r\n```\r\nI see 3 problems with this code.\r\n1. This `ckeys = set(self._channels.keys())` call is effectively useless here. The rest of the code would work just as fine if there was simply `ckeys = self._channels`\r\n2. Not the best idea to use a `[list-comprehension][0]` when we only need to find a first item of the resulting list\r\n3. The `x + 1` part is all right, but why don't we allow to reuse `x - 1` numbers too?","created_at":"2015-12-08T08:45:15Z","updated_at":"2015-12-08T08:45:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pika/pika/pulls/673/commits","review_comments_url":"https://api.github.com/repos/pika/pika/pulls/673/comments","review_comment_url":"https://api.github.com/repos/pika/pika/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pika/pika/issues/673/comments","statuses_url":"https://api.github.com/repos/pika/pika/statuses/f9de32d8cf67335583f458dcc34e4adca30777f2","head":{"label":"eugals:master","ref":"master","sha":"f9de32d8cf67335583f458dcc34e4adca30777f2","user":{"login":"eugals","id":479407,"avatar_url":"https://avatars.githubusercontent.com/u/479407?v=3","gravatar_id":"","url":"https://api.github.com/users/eugals","html_url":"https://github.com/eugals","followers_url":"https://api.github.com/users/eugals/followers","following_url":"https://api.github.com/users/eugals/following{/other_user}","gists_url":"https://api.github.com/users/eugals/gists{/gist_id}","starred_url":"https://api.github.com/users/eugals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugals/subscriptions","organizations_url":"https://api.github.com/users/eugals/orgs","repos_url":"https://api.github.com/users/eugals/repos","events_url":"https://api.github.com/users/eugals/events{/privacy}","received_events_url":"https://api.github.com/users/eugals/received_events","type":"User","site_admin":false},"repo":{"id":47606117,"name":"pika","full_name":"eugals/pika","owner":{"login":"eugals","id":479407,"avatar_url":"https://avatars.githubusercontent.com/u/479407?v=3","gravatar_id":"","url":"https://api.github.com/users/eugals","html_url":"https://github.com/eugals","followers_url":"https://api.github.com/users/eugals/followers","following_url":"https://api.github.com/users/eugals/following{/other_user}","gists_url":"https://api.github.com/users/eugals/gists{/gist_id}","starred_url":"https://api.github.com/users/eugals/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eugals/subscriptions","organizations_url":"https://api.github.com/users/eugals/orgs","repos_url":"https://api.github.com/users/eugals/repos","events_url":"https://api.github.com/users/eugals/events{/privacy}","received_events_url":"https://api.github.com/users/eugals/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eugals/pika","description":"Pure Python RabbitMQ/AMQP 0-9-1 client library","fork":true,"url":"https://api.github.com/repos/eugals/pika","forks_url":"https://api.github.com/repos/eugals/pika/forks","keys_url":"https://api.github.com/repos/eugals/pika/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eugals/pika/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eugals/pika/teams","hooks_url":"https://api.github.com/repos/eugals/pika/hooks","issue_events_url":"https://api.github.com/repos/eugals/pika/issues/events{/number}","events_url":"https://api.github.com/repos/eugals/pika/events","assignees_url":"https://api.github.com/repos/eugals/pika/assignees{/user}","branches_url":"https://api.github.com/repos/eugals/pika/branches{/branch}","tags_url":"https://api.github.com/repos/eugals/pika/tags","blobs_url":"https://api.github.com/repos/eugals/pika/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eugals/pika/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eugals/pika/git/refs{/sha}","trees_url":"https://api.github.com/repos/eugals/pika/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eugals/pika/statuses/{sha}","languages_url":"https://api.github.com/repos/eugals/pika/languages","stargazers_url":"https://api.github.com/repos/eugals/pika/stargazers","contributors_url":"https://api.github.com/repos/eugals/pika/contributors","subscribers_url":"https://api.github.com/repos/eugals/pika/subscribers","subscription_url":"https://api.github.com/repos/eugals/pika/subscription","commits_url":"https://api.github.com/repos/eugals/pika/commits{/sha}","git_commits_url":"https://api.github.com/repos/eugals/pika/git/commits{/sha}","comments_url":"https://api.github.com/repos/eugals/pika/comments{/number}","issue_comment_url":"https://api.github.com/repos/eugals/pika/issues/comments{/number}","contents_url":"https://api.github.com/repos/eugals/pika/contents/{+path}","compare_url":"https://api.github.com/repos/eugals/pika/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eugals/pika/merges","archive_url":"https://api.github.com/repos/eugals/pika/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eugals/pika/downloads","issues_url":"https://api.github.com/repos/eugals/pika/issues{/number}","pulls_url":"https://api.github.com/repos/eugals/pika/pulls{/number}","milestones_url":"https://api.github.com/repos/eugals/pika/milestones{/number}","notifications_url":"https://api.github.com/repos/eugals/pika/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eugals/pika/labels{/name}","releases_url":"https://api.github.com/repos/eugals/pika/releases{/id}","created_at":"2015-12-08T07:30:49Z","updated_at":"2015-12-08T07:30:50Z","pushed_at":"2015-12-08T08:25:27Z","git_url":"git://github.com/eugals/pika.git","ssh_url":"git@github.com:eugals/pika.git","clone_url":"https://github.com/eugals/pika.git","svn_url":"https://github.com/eugals/pika","homepage":"http://pika.readthedocs.org","size":5268,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"pika:master","ref":"master","sha":"d8a782d97579cd96ed67ccfb55f63ca8fdafa199","user":{"login":"pika","id":660428,"avatar_url":"https://avatars.githubusercontent.com/u/660428?v=3","gravatar_id":"","url":"https://api.github.com/users/pika","html_url":"https://github.com/pika","followers_url":"https://api.github.com/users/pika/followers","following_url":"https://api.github.com/users/pika/following{/other_user}","gists_url":"https://api.github.com/users/pika/gists{/gist_id}","starred_url":"https://api.github.com/users/pika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pika/subscriptions","organizations_url":"https://api.github.com/users/pika/orgs","repos_url":"https://api.github.com/users/pika/repos","events_url":"https://api.github.com/users/pika/events{/privacy}","received_events_url":"https://api.github.com/users/pika/received_events","type":"Organization","site_admin":false},"repo":{"id":342869,"name":"pika","full_name":"pika/pika","owner":{"login":"pika","id":660428,"avatar_url":"https://avatars.githubusercontent.com/u/660428?v=3","gravatar_id":"","url":"https://api.github.com/users/pika","html_url":"https://github.com/pika","followers_url":"https://api.github.com/users/pika/followers","following_url":"https://api.github.com/users/pika/following{/other_user}","gists_url":"https://api.github.com/users/pika/gists{/gist_id}","starred_url":"https://api.github.com/users/pika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pika/subscriptions","organizations_url":"https://api.github.com/users/pika/orgs","repos_url":"https://api.github.com/users/pika/repos","events_url":"https://api.github.com/users/pika/events{/privacy}","received_events_url":"https://api.github.com/users/pika/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pika/pika","description":"Pure Python RabbitMQ/AMQP 0-9-1 client library","fork":false,"url":"https://api.github.com/repos/pika/pika","forks_url":"https://api.github.com/repos/pika/pika/forks","keys_url":"https://api.github.com/repos/pika/pika/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pika/pika/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pika/pika/teams","hooks_url":"https://api.github.com/repos/pika/pika/hooks","issue_events_url":"https://api.github.com/repos/pika/pika/issues/events{/number}","events_url":"https://api.github.com/repos/pika/pika/events","assignees_url":"https://api.github.com/repos/pika/pika/assignees{/user}","branches_url":"https://api.github.com/repos/pika/pika/branches{/branch}","tags_url":"https://api.github.com/repos/pika/pika/tags","blobs_url":"https://api.github.com/repos/pika/pika/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pika/pika/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pika/pika/git/refs{/sha}","trees_url":"https://api.github.com/repos/pika/pika/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pika/pika/statuses/{sha}","languages_url":"https://api.github.com/repos/pika/pika/languages","stargazers_url":"https://api.github.com/repos/pika/pika/stargazers","contributors_url":"https://api.github.com/repos/pika/pika/contributors","subscribers_url":"https://api.github.com/repos/pika/pika/subscribers","subscription_url":"https://api.github.com/repos/pika/pika/subscription","commits_url":"https://api.github.com/repos/pika/pika/commits{/sha}","git_commits_url":"https://api.github.com/repos/pika/pika/git/commits{/sha}","comments_url":"https://api.github.com/repos/pika/pika/comments{/number}","issue_comment_url":"https://api.github.com/repos/pika/pika/issues/comments{/number}","contents_url":"https://api.github.com/repos/pika/pika/contents/{+path}","compare_url":"https://api.github.com/repos/pika/pika/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pika/pika/merges","archive_url":"https://api.github.com/repos/pika/pika/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pika/pika/downloads","issues_url":"https://api.github.com/repos/pika/pika/issues{/number}","pulls_url":"https://api.github.com/repos/pika/pika/pulls{/number}","milestones_url":"https://api.github.com/repos/pika/pika/milestones{/number}","notifications_url":"https://api.github.com/repos/pika/pika/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pika/pika/labels{/name}","releases_url":"https://api.github.com/repos/pika/pika/releases{/id}","created_at":"2009-10-19T23:22:02Z","updated_at":"2015-12-08T06:41:39Z","pushed_at":"2015-12-07T23:24:57Z","git_url":"git://github.com/pika/pika.git","ssh_url":"git@github.com:pika/pika.git","clone_url":"https://github.com/pika/pika.git","svn_url":"https://github.com/pika/pika","homepage":"http://pika.readthedocs.org","size":18903,"stargazers_count":897,"watchers_count":897,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":324,"mirror_url":null,"open_issues_count":71,"forks":324,"open_issues":71,"watchers":897,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pika/pika/pulls/673"},"html":{"href":"https://github.com/pika/pika/pull/673"},"issue":{"href":"https://api.github.com/repos/pika/pika/issues/673"},"comments":{"href":"https://api.github.com/repos/pika/pika/issues/673/comments"},"review_comments":{"href":"https://api.github.com/repos/pika/pika/pulls/673/comments"},"review_comment":{"href":"https://api.github.com/repos/pika/pika/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pika/pika/pulls/673/commits"},"statuses":{"href":"https://api.github.com/repos/pika/pika/statuses/f9de32d8cf67335583f458dcc34e4adca30777f2"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":8,"deletions":5,"changed_files":1}}