{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/4001","labels_url":"https://api.github.com/repos/astropy/astropy/issues/4001/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/4001/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/4001/events","html_url":"https://github.com/astropy/astropy/pull/4001","id":96902204,"number":4001,"title":"Miscellaneous minor refactoring of the unit formatters","user":{"login":"embray","id":676149,"avatar_url":"https://avatars.githubusercontent.com/u/676149?v=3","gravatar_id":"","url":"https://api.github.com/users/embray","html_url":"https://github.com/embray","followers_url":"https://api.github.com/users/embray/followers","following_url":"https://api.github.com/users/embray/following{/other_user}","gists_url":"https://api.github.com/users/embray/gists{/gist_id}","starred_url":"https://api.github.com/users/embray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embray/subscriptions","organizations_url":"https://api.github.com/users/embray/orgs","repos_url":"https://api.github.com/users/embray/repos","events_url":"https://api.github.com/users/embray/events{/privacy}","received_events_url":"https://api.github.com/users/embray/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/astropy/astropy/labels/Affects-release","name":"Affects-release","color":"0052cc"},{"url":"https://api.github.com/repos/astropy/astropy/labels/Performance","name":"Performance","color":"bfe5bf"},{"url":"https://api.github.com/repos/astropy/astropy/labels/units","name":"units","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/astropy/astropy/milestones/20","html_url":"https://github.com/astropy/astropy/milestones/v1.1.0","labels_url":"https://api.github.com/repos/astropy/astropy/milestones/20/labels","id":907426,"number":20,"title":"v1.1.0","description":"","creator":{"login":"eteq","id":346587,"avatar_url":"https://avatars.githubusercontent.com/u/346587?v=3","gravatar_id":"","url":"https://api.github.com/users/eteq","html_url":"https://github.com/eteq","followers_url":"https://api.github.com/users/eteq/followers","following_url":"https://api.github.com/users/eteq/following{/other_user}","gists_url":"https://api.github.com/users/eteq/gists{/gist_id}","starred_url":"https://api.github.com/users/eteq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eteq/subscriptions","organizations_url":"https://api.github.com/users/eteq/orgs","repos_url":"https://api.github.com/users/eteq/repos","events_url":"https://api.github.com/users/eteq/events{/privacy}","received_events_url":"https://api.github.com/users/eteq/received_events","type":"User","site_admin":false},"open_issues":42,"closed_issues":90,"state":"open","created_at":"2014-12-17T20:05:23Z","updated_at":"2015-07-30T22:35:19Z","due_on":"2015-07-23T04:00:00Z","closed_at":null},"comments":7,"created_at":"2015-07-23T20:47:33Z","updated_at":"2015-07-30T22:54:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/astropy/astropy/pulls/4001","html_url":"https://github.com/astropy/astropy/pull/4001","diff_url":"https://github.com/astropy/astropy/pull/4001.diff","patch_url":"https://github.com/astropy/astropy/pull/4001.patch"},"body":"Most of these changes were driven by the observation I made, upon going to make some changes for #3986, that on some of the formatter classes (including the `Base` class) the `to_string` method was a normal instance method, while on others (about half) it was a `classmethod`.  This incongruity bugged me.\r\n\r\nAfter looking over the other classes I decided it would be possible to make the `parse` and `to_string` methods on all the formatter classes into `classmethods`, so that now each formatter class is basically acting as a singleton (it would actually be a good use case for a general Singleton type, but I decided to leave that as an exercise for another time).\r\n\r\nI think there are probably others bits of repetition between the formatter implementations, but I think that's about all I feel like addressing for now.\r\n\r\nThis also removed all inline imports from `parse` and `to_string` methods.  A bit of a hack, but doable.  Between eliminating formatter instantiation and inline imports, the time to instantiate a `Unit` from a string with the generic formatter (after already using the formatter at least once, so parser/lexer setup is excluded from this timing) went from about 13.1µs to about 9.2µs, or about 30%.  Not super-dramatic, but still worthwhile."},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/126514062","html_url":"https://github.com/astropy/astropy/pull/4001#issuecomment-126514062","issue_url":"https://api.github.com/repos/astropy/astropy/issues/4001","id":126514062,"user":{"login":"embray","id":676149,"avatar_url":"https://avatars.githubusercontent.com/u/676149?v=3","gravatar_id":"","url":"https://api.github.com/users/embray","html_url":"https://github.com/embray","followers_url":"https://api.github.com/users/embray/followers","following_url":"https://api.github.com/users/embray/following{/other_user}","gists_url":"https://api.github.com/users/embray/gists{/gist_id}","starred_url":"https://api.github.com/users/embray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/embray/subscriptions","organizations_url":"https://api.github.com/users/embray/orgs","repos_url":"https://api.github.com/users/embray/repos","events_url":"https://api.github.com/users/embray/events{/privacy}","received_events_url":"https://api.github.com/users/embray/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T22:54:10Z","updated_at":"2015-07-30T22:54:10Z","body":"For some reason this wasn't re-picked up by CI watchers when I rebased.  Trying again...."}}