{"action":"created","comment":{"url":"https://api.github.com/repos/edx/opaque-keys/pulls/comments/72329378","id":72329378,"diff_hunk":"@@ -260,7 +267,45 @@ def _from_string(cls, serialized):\n         if parse['version_guid']:\n             parse['version_guid'] = cls.as_object_id(parse['version_guid'])\n \n-        return cls(**{key: parse.get(key) for key in cls.KEY_FIELDS})\n+        parsed_values = tuple(parse.get(key) for key in cls.KEY_FIELDS)\n+\n+        # Include the class name in the cache key so that we don't have\n+        # collisions with sub-classes.\n+        cache_key = (cls.__class__, parsed_values)","path":"opaque_keys/edx/locator.py","position":32,"original_position":32,"commit_id":"007dd89e41a28589a50573795ea9daf06c92b2d4","original_commit_id":"007dd89e41a28589a50573795ea9daf06c92b2d4","user":{"login":"jmbowman","id":1005375,"avatar_url":"https://avatars.githubusercontent.com/u/1005375?v=3","gravatar_id":"","url":"https://api.github.com/users/jmbowman","html_url":"https://github.com/jmbowman","followers_url":"https://api.github.com/users/jmbowman/followers","following_url":"https://api.github.com/users/jmbowman/following{/other_user}","gists_url":"https://api.github.com/users/jmbowman/gists{/gist_id}","starred_url":"https://api.github.com/users/jmbowman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmbowman/subscriptions","organizations_url":"https://api.github.com/users/jmbowman/orgs","repos_url":"https://api.github.com/users/jmbowman/repos","events_url":"https://api.github.com/users/jmbowman/events{/privacy}","received_events_url":"https://api.github.com/users/jmbowman/received_events","type":"User","site_admin":false},"body":"The comment says class name, the code uses the class object.  The latter is probably more robust (could have multiple classes with the same name in different packages), so just update the comment?","created_at":"2016-07-26T20:23:33Z","updated_at":"2016-07-26T20:23:33Z","html_url":"https://github.com/edx/opaque-keys/pull/67#discussion_r72329378","pull_request_url":"https://api.github.com/repos/edx/opaque-keys/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/comments/72329378"},"html":{"href":"https://github.com/edx/opaque-keys/pull/67#discussion_r72329378"},"pull_request":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/edx/opaque-keys/pulls/67","id":59963244,"html_url":"https://github.com/edx/opaque-keys/pull/67","diff_url":"https://github.com/edx/opaque-keys/pull/67.diff","patch_url":"https://github.com/edx/opaque-keys/pull/67.patch","issue_url":"https://api.github.com/repos/edx/opaque-keys/issues/67","number":67,"state":"open","locked":false,"title":"PERF: Optimize key hashing and equality comparison","user":{"login":"ormsbee","id":41625,"avatar_url":"https://avatars.githubusercontent.com/u/41625?v=3","gravatar_id":"","url":"https://api.github.com/users/ormsbee","html_url":"https://github.com/ormsbee","followers_url":"https://api.github.com/users/ormsbee/followers","following_url":"https://api.github.com/users/ormsbee/following{/other_user}","gists_url":"https://api.github.com/users/ormsbee/gists{/gist_id}","starred_url":"https://api.github.com/users/ormsbee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ormsbee/subscriptions","organizations_url":"https://api.github.com/users/ormsbee/orgs","repos_url":"https://api.github.com/users/ormsbee/repos","events_url":"https://api.github.com/users/ormsbee/events{/privacy}","received_events_url":"https://api.github.com/users/ormsbee/received_events","type":"User","site_admin":false},"body":"Okay folks, thank you for your patience. I think this is now in a reviewable state.\r\n\r\nLooking at the progress page of a fairly large course (~1.3K blocks) here are three things that happen over and over to OpaqueKeys \r\n\r\n1. Hashing (114K times)\r\n2. Serialization to unicode (49K times)\r\n3. Equality checks (19K times)\r\n\r\nThis PR tries to address those issues by:\r\n\r\n1. Storing the hash explicitly as an integer attribute, so we can throw it back with no work.\r\n2. Storing the serialized unicode representation (which is simple, since that's usually how it's constructed).\r\n3. Intern the OpaqueKeys.\r\n\r\nThe third one helps avoiding the extra work of hashing and serialization, but it also makes equality faster because we can short circuit them using object identity and hash value (both of which are cheap to check).\r\n\r\nMy biggest concern is the possible memory leak in the explicit cache pool. I use a `WeakValueDictionary`, but I don't know as that's enough. On the bright side, I think we create far fewer OpaqueKeys during a given request now...\r\n\r\n@nedbat, @nasthagiri, @doctoryes, @cpennington: May I get a review from two of you folks?","created_at":"2016-02-19T15:25:02Z","updated_at":"2016-07-26T20:23:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fc931c6b3b3339cabac1efc2e9d2fe7270d61507","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/opaque-keys/pulls/67/commits","review_comments_url":"https://api.github.com/repos/edx/opaque-keys/pulls/67/comments","review_comment_url":"https://api.github.com/repos/edx/opaque-keys/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/opaque-keys/issues/67/comments","statuses_url":"https://api.github.com/repos/edx/opaque-keys/statuses/007dd89e41a28589a50573795ea9daf06c92b2d4","head":{"label":"edx:ormsbee/str_key","ref":"ormsbee/str_key","sha":"007dd89e41a28589a50573795ea9daf06c92b2d4","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":20107950,"name":"opaque-keys","full_name":"edx/opaque-keys","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/opaque-keys","description":"","fork":false,"url":"https://api.github.com/repos/edx/opaque-keys","forks_url":"https://api.github.com/repos/edx/opaque-keys/forks","keys_url":"https://api.github.com/repos/edx/opaque-keys/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/opaque-keys/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/opaque-keys/teams","hooks_url":"https://api.github.com/repos/edx/opaque-keys/hooks","issue_events_url":"https://api.github.com/repos/edx/opaque-keys/issues/events{/number}","events_url":"https://api.github.com/repos/edx/opaque-keys/events","assignees_url":"https://api.github.com/repos/edx/opaque-keys/assignees{/user}","branches_url":"https://api.github.com/repos/edx/opaque-keys/branches{/branch}","tags_url":"https://api.github.com/repos/edx/opaque-keys/tags","blobs_url":"https://api.github.com/repos/edx/opaque-keys/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/opaque-keys/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/opaque-keys/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/opaque-keys/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/opaque-keys/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/opaque-keys/languages","stargazers_url":"https://api.github.com/repos/edx/opaque-keys/stargazers","contributors_url":"https://api.github.com/repos/edx/opaque-keys/contributors","subscribers_url":"https://api.github.com/repos/edx/opaque-keys/subscribers","subscription_url":"https://api.github.com/repos/edx/opaque-keys/subscription","commits_url":"https://api.github.com/repos/edx/opaque-keys/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/opaque-keys/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/opaque-keys/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/opaque-keys/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/opaque-keys/contents/{+path}","compare_url":"https://api.github.com/repos/edx/opaque-keys/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/opaque-keys/merges","archive_url":"https://api.github.com/repos/edx/opaque-keys/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/opaque-keys/downloads","issues_url":"https://api.github.com/repos/edx/opaque-keys/issues{/number}","pulls_url":"https://api.github.com/repos/edx/opaque-keys/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/opaque-keys/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/opaque-keys/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/opaque-keys/labels{/name}","releases_url":"https://api.github.com/repos/edx/opaque-keys/releases{/id}","deployments_url":"https://api.github.com/repos/edx/opaque-keys/deployments","created_at":"2014-05-23T17:24:54Z","updated_at":"2016-01-25T23:59:12Z","pushed_at":"2016-07-24T14:06:15Z","git_url":"git://github.com/edx/opaque-keys.git","ssh_url":"git@github.com:edx/opaque-keys.git","clone_url":"https://github.com/edx/opaque-keys.git","svn_url":"https://github.com/edx/opaque-keys","homepage":null,"size":287,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":3,"forks":15,"open_issues":3,"watchers":4,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"f3942654aa9e341c3d1d4b459ee705a2c5a2dc73","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":20107950,"name":"opaque-keys","full_name":"edx/opaque-keys","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/opaque-keys","description":"","fork":false,"url":"https://api.github.com/repos/edx/opaque-keys","forks_url":"https://api.github.com/repos/edx/opaque-keys/forks","keys_url":"https://api.github.com/repos/edx/opaque-keys/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/opaque-keys/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/opaque-keys/teams","hooks_url":"https://api.github.com/repos/edx/opaque-keys/hooks","issue_events_url":"https://api.github.com/repos/edx/opaque-keys/issues/events{/number}","events_url":"https://api.github.com/repos/edx/opaque-keys/events","assignees_url":"https://api.github.com/repos/edx/opaque-keys/assignees{/user}","branches_url":"https://api.github.com/repos/edx/opaque-keys/branches{/branch}","tags_url":"https://api.github.com/repos/edx/opaque-keys/tags","blobs_url":"https://api.github.com/repos/edx/opaque-keys/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/opaque-keys/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/opaque-keys/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/opaque-keys/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/opaque-keys/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/opaque-keys/languages","stargazers_url":"https://api.github.com/repos/edx/opaque-keys/stargazers","contributors_url":"https://api.github.com/repos/edx/opaque-keys/contributors","subscribers_url":"https://api.github.com/repos/edx/opaque-keys/subscribers","subscription_url":"https://api.github.com/repos/edx/opaque-keys/subscription","commits_url":"https://api.github.com/repos/edx/opaque-keys/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/opaque-keys/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/opaque-keys/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/opaque-keys/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/opaque-keys/contents/{+path}","compare_url":"https://api.github.com/repos/edx/opaque-keys/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/opaque-keys/merges","archive_url":"https://api.github.com/repos/edx/opaque-keys/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/opaque-keys/downloads","issues_url":"https://api.github.com/repos/edx/opaque-keys/issues{/number}","pulls_url":"https://api.github.com/repos/edx/opaque-keys/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/opaque-keys/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/opaque-keys/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/opaque-keys/labels{/name}","releases_url":"https://api.github.com/repos/edx/opaque-keys/releases{/id}","deployments_url":"https://api.github.com/repos/edx/opaque-keys/deployments","created_at":"2014-05-23T17:24:54Z","updated_at":"2016-01-25T23:59:12Z","pushed_at":"2016-07-24T14:06:15Z","git_url":"git://github.com/edx/opaque-keys.git","ssh_url":"git@github.com:edx/opaque-keys.git","clone_url":"https://github.com/edx/opaque-keys.git","svn_url":"https://github.com/edx/opaque-keys","homepage":null,"size":287,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":3,"forks":15,"open_issues":3,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/67"},"html":{"href":"https://github.com/edx/opaque-keys/pull/67"},"issue":{"href":"https://api.github.com/repos/edx/opaque-keys/issues/67"},"comments":{"href":"https://api.github.com/repos/edx/opaque-keys/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/opaque-keys/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/edx/opaque-keys/statuses/007dd89e41a28589a50573795ea9daf06c92b2d4"}}}}
{"actor":{"display_login":"jmbowman"}}