{"action":"created","issue":{"url":"https://api.github.com/repos/falconry/falcon/issues/637","labels_url":"https://api.github.com/repos/falconry/falcon/issues/637/labels{/name}","comments_url":"https://api.github.com/repos/falconry/falcon/issues/637/comments","events_url":"https://api.github.com/repos/falconry/falcon/issues/637/events","html_url":"https://github.com/falconry/falcon/issues/637","id":112262971,"number":637,"title":"Using env.get instead of if...in","user":{"login":"ueg1990","id":3393794,"avatar_url":"https://avatars.githubusercontent.com/u/3393794?v=3","gravatar_id":"","url":"https://api.github.com/users/ueg1990","html_url":"https://github.com/ueg1990","followers_url":"https://api.github.com/users/ueg1990/followers","following_url":"https://api.github.com/users/ueg1990/following{/other_user}","gists_url":"https://api.github.com/users/ueg1990/gists{/gist_id}","starred_url":"https://api.github.com/users/ueg1990/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ueg1990/subscriptions","organizations_url":"https://api.github.com/users/ueg1990/orgs","repos_url":"https://api.github.com/users/ueg1990/repos","events_url":"https://api.github.com/users/ueg1990/events{/privacy}","received_events_url":"https://api.github.com/users/ueg1990/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-20T01:05:11Z","updated_at":"2015-10-21T12:47:33Z","closed_at":null,"body":"I had a question about the following piece of code in falcon.request.Request:\r\n\r\n```python\r\n# PERF(kgriffs): if...in is faster than using env.get(...)\r\n        if 'QUERY_STRING' in env:\r\n            self.query_string = env['QUERY_STRING']\r\n\r\n            if self.query_string:\r\n                self._params = parse_query_string(\r\n                    self.query_string,\r\n                    keep_blank_qs_values=self.options.keep_blank_qs_values,\r\n                )\r\n\r\n            else:\r\n                self._params = {}\r\n\r\n        else:\r\n            self.query_string = ''\r\n            self._params = {}\r\n```\r\n\r\nFor the part,\r\n```python\r\n if 'QUERY_STRING' in env:\r\n     self.query_string = env['QUERY_STRING']\r\n```\r\nArent you performing two hash operations (one for checking and one for retrieving)? Based on that, env.get should be better? "},"comment":{"url":"https://api.github.com/repos/falconry/falcon/issues/comments/149884241","html_url":"https://github.com/falconry/falcon/issues/637#issuecomment-149884241","issue_url":"https://api.github.com/repos/falconry/falcon/issues/637","id":149884241,"user":{"login":"swizzard","id":1909918,"avatar_url":"https://avatars.githubusercontent.com/u/1909918?v=3","gravatar_id":"","url":"https://api.github.com/users/swizzard","html_url":"https://github.com/swizzard","followers_url":"https://api.github.com/users/swizzard/followers","following_url":"https://api.github.com/users/swizzard/following{/other_user}","gists_url":"https://api.github.com/users/swizzard/gists{/gist_id}","starred_url":"https://api.github.com/users/swizzard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swizzard/subscriptions","organizations_url":"https://api.github.com/users/swizzard/orgs","repos_url":"https://api.github.com/users/swizzard/repos","events_url":"https://api.github.com/users/swizzard/events{/privacy}","received_events_url":"https://api.github.com/users/swizzard/received_events","type":"User","site_admin":false},"created_at":"2015-10-21T12:47:33Z","updated_at":"2015-10-21T12:47:33Z","body":"Arguably more Pythonic, too (EAFP and all that.)\n\nOn Wed, Oct 21, 2015 at 12:16 AM, Philip Tzou <notifications@github.com>\nwrote:\n\n> This's faster than both .get() and if ... in ...:\n>\n> try:\n>     self.query_string = env['QUERY_STRING']except KeyError:\n>     pass\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/falconry/falcon/issues/637#issuecomment-149777120>.\n>\n\n\n\n-- \n.\n"}}