{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/5890","labels_url":"https://api.github.com/repos/numpy/numpy/issues/5890/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/5890/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/5890/events","html_url":"https://github.com/numpy/numpy/pull/5890","id":77523953,"number":5890,"title":"BUG: Don't use longlong for PyLong if it isn't larger than long","user":{"login":"jaimefrio","id":3343990,"avatar_url":"https://avatars.githubusercontent.com/u/3343990?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimefrio","html_url":"https://github.com/jaimefrio","followers_url":"https://api.github.com/users/jaimefrio/followers","following_url":"https://api.github.com/users/jaimefrio/following{/other_user}","gists_url":"https://api.github.com/users/jaimefrio/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimefrio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimefrio/subscriptions","organizations_url":"https://api.github.com/users/jaimefrio/orgs","repos_url":"https://api.github.com/users/jaimefrio/repos","events_url":"https://api.github.com/users/jaimefrio/events{/privacy}","received_events_url":"https://api.github.com/users/jaimefrio/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.core","name":"component: numpy.core","color":"ff0000"},{"url":"https://api.github.com/repos/numpy/numpy/labels/Defect","name":"Defect","color":"444444"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-18T06:31:45Z","updated_at":"2015-05-29T05:25:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/5890","html_url":"https://github.com/numpy/numpy/pull/5890","diff_url":"https://github.com/numpy/numpy/pull/5890.diff","patch_url":"https://github.com/numpy/numpy/pull/5890.patch"},"body":"Closes #5801.\r\n\r\nPyLong types are only converted to npy_longlong if it is larger\r\nthan npy_long."},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/106692313","html_url":"https://github.com/numpy/numpy/pull/5890#issuecomment-106692313","issue_url":"https://api.github.com/repos/numpy/numpy/issues/5890","id":106692313,"user":{"login":"jaimefrio","id":3343990,"avatar_url":"https://avatars.githubusercontent.com/u/3343990?v=3","gravatar_id":"","url":"https://api.github.com/users/jaimefrio","html_url":"https://github.com/jaimefrio","followers_url":"https://api.github.com/users/jaimefrio/followers","following_url":"https://api.github.com/users/jaimefrio/following{/other_user}","gists_url":"https://api.github.com/users/jaimefrio/gists{/gist_id}","starred_url":"https://api.github.com/users/jaimefrio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaimefrio/subscriptions","organizations_url":"https://api.github.com/users/jaimefrio/orgs","repos_url":"https://api.github.com/users/jaimefrio/repos","events_url":"https://api.github.com/users/jaimefrio/events{/privacy}","received_events_url":"https://api.github.com/users/jaimefrio/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T05:24:59Z","updated_at":"2015-05-29T05:24:59Z","body":"I have taken a second look into this, and it really seems there is no way out of not using `long long` when a smaller type will do:\r\n\r\n * Comparison of dtypes does the right thing already:\r\n\r\n```\r\n>>> dt1 = np.dtype(np.int64)\r\n>>> dt2 = np.dtype(np.longlong)\r\n>>> dt1.num == dt2.num  # They are different types...\r\nFalse\r\n>>> dt1 == dt2  # ...but they compare equal.\r\nTrue\r\n```\r\n\r\n * Inheritance is also properly set up, as both types inherit from the same base types:\r\n\r\n```\r\n>>> np.int64.__bases__\r\n(numpy.signedinteger, int)\r\n>>> np.longlong.__bases__\r\n(numpy.signedinteger, int)\r\n```\r\n\r\nThis is not enough to stop this:\r\n\r\n```\r\n>>> isinstance(dt2, np.int64)\r\nFalse\r\n```\r\n\r\nfrom returning a correct, yet awfully confusing result. Especially given that:\r\n\r\n```\r\n>>> np.longlong.__name__\r\n'int64'\r\n```\r\n\r\nSo really the only valid solution is making sure that we always issue the smallest numbered type that fits the requested size, which is what this PR attempts to do."}}