)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"f29b4516e7ebc6c100c8e9a660a6be43fbef15f8","unresolved":false,"context_lines":[{"line_number":7,"context_line":"Use standard library function"},{"line_number":8,"context_line":""},{"line_number":9,"context_line":"Usually, No of characters in FORBIDDEN_CHARS are less"},{"line_number":10,"context_line":"when compared with path,"},{"line_number":11,"context_line":""},{"line_number":12,"context_line":"Change-Id: I78b7e0ff4cae1cc90e8d29d7bddcec7fe0ba4bd4"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":3,"id":"fa80f949_8b1493f5","line":10,"updated":"2015-11-04 11:31:53.000000000","message":"This statement didn\u0027t parse for me, maybe:\n\nUsually, the number of characters in FORBIDDEN_CHARS are fewer than the number of characters in the req.path - so it\u0027s better to use the smaller count for the outer loop.","commit_id":"b28dd722db0e8a95b68fd74e4efae0773f4b812c"}],"swift/common/middleware/name_check.py":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"f540bd33252a03ae73af00a5309bc08a31d7d842","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if c in self.forbidden_chars:"},{"line_number":84,"context_line":"                return True"},{"line_number":85,"context_line":"            else:"},{"line_number":86,"context_line":"                pass"},{"line_number":87,"context_line":"        return False"},{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    def check_length(self, req):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa80f949_da0cae44","side":"PARENT","line":86,"updated":"2015-11-04 09:18:34.000000000","message":"nice!\n\nreturn any(c in self.forbidden_chars for c in unquote(req.path))","commit_id":"7242c4a006c39f6f5a3e53607dc5e2998328b3c2"},{"author":{"_account_id":15701,"name":"venkatesh","email":"p.venkatesh551@gmail.com","username":"venkatesh"},"change_message_id":"58547d10c83e1f22753fac9220596bab9fcc4fa9","unresolved":false,"context_lines":[{"line_number":83,"context_line":"            if c in self.forbidden_chars:"},{"line_number":84,"context_line":"                return True"},{"line_number":85,"context_line":"            else:"},{"line_number":86,"context_line":"                pass"},{"line_number":87,"context_line":"        return False"},{"line_number":88,"context_line":""},{"line_number":89,"context_line":"    def check_length(self, req):"}],"source_content_type":"text/x-python","patch_set":1,"id":"fa80f949_3f5fe942","side":"PARENT","line":86,"in_reply_to":"fa80f949_da0cae44","updated":"2015-11-04 10:07:23.000000000","message":"yes, It gives shorter code, but performance wise, not much difference.\n\nhttps://docs.python.org/2/library/functions.html#any","commit_id":"7242c4a006c39f6f5a3e53607dc5e2998328b3c2"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"f29b4516e7ebc6c100c8e9a660a6be43fbef15f8","unresolved":false,"context_lines":[{"line_number":79,"context_line":"        self.logger.debug(\"name_check: self.forbidden_chars %s\" %"},{"line_number":80,"context_line":"                          self.forbidden_chars)"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":"        return any((c in unquote(req.path)) for c in self.forbidden_chars)"},{"line_number":83,"context_line":""},{"line_number":84,"context_line":"    def check_length(self, req):"},{"line_number":85,"context_line":"        \u0027\u0027\u0027"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa80f949_2bc5678d","line":82,"updated":"2015-11-04 11:31:53.000000000","message":"well now that you\u0027ve flipped the order and mentioned \"performance wise\" you got me thinking about these two strings relative cardinality...\n\nreq.path could be thousands of characters - where as the default forbidden_chars is relatively short.\n\nDid you try to timeit?\n\n    vagrant@saio:~$ python -m timeit -s \"from swift.common.middleware.name_check import FORBIDDEN_CHARS\" \"any(c in FORBIDDEN_CHARS for c in \u0027http://saio:8080/v1/AUTH_test/test/test\u0027)\"\n    100000 loops, best of 3: 3.21 usec per loop\n    vagrant@saio:~$ python -m timeit -s \"from swift.common.middleware.name_check import FORBIDDEN_CHARS\" \"any(c in \u0027http://saio:8080/v1/AUTH_test/test/test\u0027 for c in FORBIDDEN_CHARS)\"\n    1000000 loops, best of 3: 0.881 usec per loop\n\n\nThis is an interesting result for me.  I guess since the string comparison is all happening in c it\u0027s runtime is dwarfed by the number of chars iterated over in python.","commit_id":"b28dd722db0e8a95b68fd74e4efae0773f4b812c"},{"author":{"_account_id":15701,"name":"venkatesh","email":"p.venkatesh551@gmail.com","username":"venkatesh"},"change_message_id":"2936a289e92d5a30c4542f564ca60bf89b8314e6","unresolved":false,"context_lines":[{"line_number":79,"context_line":"        self.logger.debug(\"name_check: self.forbidden_chars %s\" %"},{"line_number":80,"context_line":"                          self.forbidden_chars)"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":"        return any((c in unquote(req.path)) for c in self.forbidden_chars)"},{"line_number":83,"context_line":""},{"line_number":84,"context_line":"    def check_length(self, req):"},{"line_number":85,"context_line":"        \u0027\u0027\u0027"}],"source_content_type":"text/x-python","patch_set":3,"id":"fa80f949_4b878bb5","line":82,"in_reply_to":"fa80f949_2bc5678d","updated":"2015-11-04 11:47:48.000000000","message":"performance comparison I have done. \n\nStill I am thinking using looping construct is better than using  method \"any\"\n\nfor c in self.forbidden_chars:\n      if c in unquote(req.path):\n             return True\nreturn False\n\nvs \n\n\nIn the second approach we are passing generator to \"any\" method.\ngenerator is a true/false for every character in the FORBIDDEN_CHARS\n\nCan you tell which one is better?","commit_id":"b28dd722db0e8a95b68fd74e4efae0773f4b812c"}]}
