{"action":"closed","issue":{"url":"https://api.github.com/repos/msgpack/msgpack-python/issues/150","labels_url":"https://api.github.com/repos/msgpack/msgpack-python/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/msgpack/msgpack-python/issues/150/comments","events_url":"https://api.github.com/repos/msgpack/msgpack-python/issues/150/events","html_url":"https://github.com/msgpack/msgpack-python/issues/150","id":111433912,"number":150,"title":"TypeError: can't serialize np.float32(1213771) or np.int64(1213771)","user":{"login":"dragoljub","id":2701562,"avatar_url":"https://avatars.githubusercontent.com/u/2701562?v=3","gravatar_id":"","url":"https://api.github.com/users/dragoljub","html_url":"https://github.com/dragoljub","followers_url":"https://api.github.com/users/dragoljub/followers","following_url":"https://api.github.com/users/dragoljub/following{/other_user}","gists_url":"https://api.github.com/users/dragoljub/gists{/gist_id}","starred_url":"https://api.github.com/users/dragoljub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dragoljub/subscriptions","organizations_url":"https://api.github.com/users/dragoljub/orgs","repos_url":"https://api.github.com/users/dragoljub/repos","events_url":"https://api.github.com/users/dragoljub/events{/privacy}","received_events_url":"https://api.github.com/users/dragoljub/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-14T16:13:58Z","updated_at":"2015-10-14T16:23:04Z","closed_at":"2015-10-14T16:23:04Z","body":"I found these strange corner cases when serializing np.float32 and np.int64 values. What's strange is that np.int32 and np.float64 for the same underlying value works.\r\n\r\nAny ideas whats going on? :question: \r\n\r\n```python\r\nimport msgpack\r\nimport numpy as np\r\n\r\nIn [1]: np.__version__\r\n\r\nOut[1]: '1.9.2'\r\n\r\nIn [2]: msgpack.version\r\n\r\nOut[2]: (0, 4, 6)\r\n\r\nIn [3]: msgpack.packb([np.float32(1213771)])\r\n\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-3-a34bd885d43f> in <module>()\r\n----> 1 msgpack.packb([np.float32(1213771)])\r\n\r\nD:\\Python27\\lib\\site-packages\\msgpack\\__init__.pyc in packb(o, **kwargs)\r\n     45     See :class:`Packer` for options.\r\n     46     \"\"\"\r\n---> 47     return Packer(**kwargs).pack(o)\r\n     48 \r\n     49 # alias for compatibility to simplejson/marshal/pickle.\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer.pack (msgpack\\_packer.cpp:223)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer.pack (msgpack\\_packer.cpp:225)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer._pack (msgpack\\_packer.cpp:213)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer._pack (msgpack\\_packer.cpp:220)()\r\n\r\nTypeError: can't serialize 1213771.0\r\n\r\nIn [4]: msgpack.packb([np.int64(1213771)])\r\n\r\n---------------------------------------------------------------------------\r\nTypeError                                 Traceback (most recent call last)\r\n<ipython-input-4-dc4780e7a01d> in <module>()\r\n----> 1 msgpack.packb([np.int64(1213771)])\r\n\r\nD:\\Python27\\lib\\site-packages\\msgpack\\__init__.pyc in packb(o, **kwargs)\r\n     45     See :class:`Packer` for options.\r\n     46     \"\"\"\r\n---> 47     return Packer(**kwargs).pack(o)\r\n     48 \r\n     49 # alias for compatibility to simplejson/marshal/pickle.\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer.pack (msgpack\\_packer.cpp:223)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer.pack (msgpack\\_packer.cpp:225)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer._pack (msgpack\\_packer.cpp:213)()\r\n\r\nmsgpack\\_packer.pyx in msgpack._packer.Packer._pack (msgpack\\_packer.cpp:220)()\r\n\r\nTypeError: can't serialize 1213771\r\n\r\nIn [5]: msgpack.packb([np.int32(1213771)])\r\n\r\nOut[5]: '\\x91\\xce\\x00\\x12\\x85K'\r\n\r\nIn [6]: msgpack.packb([np.float64(1213771)])\r\n\r\nOut[6]: '\\x91\\xcbA2\\x85K\\x00\\x00\\x00\\x00'\r\n\r\n```"}}