)]}'
{"swift/common/ring/builder.py":[{"author":{"_account_id":2696,"name":"Darrell Bishop","email":"dbishop@nvidia.com","username":"darrellb"},"change_message_id":"775d2597856c3c536b462359e5e6a8397816a249","unresolved":false,"context_lines":[{"line_number":181,"context_line":"            dev.setdefault(\"region\", 1)"},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"    def __deepcopy__(self, memo):"},{"line_number":184,"context_line":"        the_copy \u003d type(self).from_dict(deepcopy(self.to_dict()))"},{"line_number":185,"context_line":"        memo[id(self)] \u003d the_copy"},{"line_number":186,"context_line":"        return the_copy"},{"line_number":187,"context_line":""}],"source_content_type":"text/x-python","patch_set":2,"id":"bab921fb_78f5b681","line":184,"updated":"2015-04-22 22:18:10.000000000","message":"I think the \"memo\" arg needs to be plumbed into that deepcopy() call.\n\n If the __deepcopy__() implementation needs to make a deep copy of a\n component, it should call the deepcopy() function with the component as\n first argument and the memo dictionary as second argument.\n\nI almost think to_dict needs to be something like:\n\n def to_dict(self, deep_copy_memo\u003dNone):\n     if deep_copy_memo is not None:\n         return {\u0027xyz\u0027: deepcopy(self.xyz, deep_copy_memo), ... }\n     else:\n         return {\u0027xyz\u0027: self.xyz, ... }\n\nAnd then our __deepcopy___\n\n def __deepcopy__(self, memo):\n     return self.__class__.from_dict(self.to_dict(deep_copy_memo\u003dmemo))\n\nThat\u0027s mildly dirty because a single kwarg is overloaded to both mean \"do a deep copy\" and \"use this memo dict when you do it\".  But I think the resulting behavior is a little better.","commit_id":"3c0b64709ec7bec51ceb319ef5befa2143fcc961"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"f6b37d46ec8d5228c57f44fb0f7c7ea8eb6cd918","unresolved":false,"context_lines":[{"line_number":182,"context_line":""},{"line_number":183,"context_line":"    def __deepcopy__(self, memo):"},{"line_number":184,"context_line":"        the_copy \u003d type(self).from_dict(deepcopy(self.to_dict(), memo))"},{"line_number":185,"context_line":"        memo[id(self)] \u003d the_copy"},{"line_number":186,"context_line":"        return the_copy"},{"line_number":187,"context_line":""},{"line_number":188,"context_line":"    def to_dict(self):"}],"source_content_type":"text/x-python","patch_set":3,"id":"bab921fb_b522faff","line":185,"updated":"2015-04-24 02:39:05.000000000","message":"this line is not helpful *at all*\n\nThere\u0027s no required convention of how to reference things in memo - it just a bag of mess that a class who is a container can use to keep track of objects it\u0027s already made copies of.  Sine we never inspect memo (nor should we since we\u0027re not a container class), there\u0027s nothing useful we could possibly put in it hoping it might be useful to someone else - it won\u0027t.\n\nNow it just so happens that stdlib containers *will* key \"the_copy\" into memo as \"id(self)\" just after this function returns (you can imagine such a container \"for item in self if item not not in memo\"\u0027ing their way though themselves and encountering one of our RingBuilders) - but again, not helpful for us to try and do their job for them.  In fact you can replace the rhs there with \"total garbage\" and making a deepcopy of a list of builders that includes duplicates will still get you the right stuff.  The duplicates never get __deepcopy__ called since the container has already memorized a deepcopy of those instances - and the first guy to get deepcopied will have his feeble attempt at a memo marker over-written *correctly* by the container since he figures if there IS anything at that key already it was probably some silly class thinking it was being \"helpful\" accidentally writing some boring nonsense in there anyway.\n\nFWIW passing the memo onto our call to deepcopy is pretty good.  If somehow two *different* builders managed to get some shared state (you can imagine maybe someone saying builderA.devs \u003d builderB.devs and then they deepcopy([builderA, builderB])) no sense in making two copies of of that attribute and uncoupling those references so... yay passing on memo!  However further plumbing into .to_dict would *not* provide any additional benefit over what dict\u0027s __deepcopy__ is already doing for us here.","commit_id":"43ace3c62893364b6e3c130df56438995627598d"}]}
