-
Notifications
You must be signed in to change notification settings - Fork 225
serialization of numpy dtypes is inconsistent and non-informative #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This difference came from numpy and Python itself. So difference behavior about np.int64 is not a issue of msgpack. There is |
I don't want to add native support of numpy dtypes. msgpack has |
@methane thanks. I agree this is not an issue of msgpack and that python really made things difficult with all the changes from 2 to 3. Given that msgpack-python is however for use with python and numpy is increasingly ubiquitous, does it make sense to consider some kind of added feature? Maybe the following np.asscalar() workaround could be performed under the hood for numpy dtypes, or a flag added to do that? I believe this would create expected behavior. As a work around, using np.asscalar() works, example: msgpack.loads(msgpack.dumps(np.asscalar(np.float32(1)))) |
The quick issue is as follows. msgpack serializes some numpy dtypes, but raises an uninformative TypeError for others in different ways depending on python 2.7 or 3.4 (np.int64).
Possible solutions:
The motivation for support of numpy. We are working with msgpack to serialize/access objects for storage in HDF5 with pytables. The combination is quite simple and powerful. It addresses a major need of very efficiently (size and speed) storing complex data to disk and back. And solves an issue with json which is that integers used as keys in dictionaries are deserialized correctly with msgpack. Pytables relies on ndarray containers from numpy to return data. The issue only arises then when combining data that has already been read from pytables and is then being packed to be written again, which lead to a tricky bug because of the inconsistent behavior.
The text was updated successfully, but these errors were encountered: