[Numpy-discussion] Question about dtype
Valentin Haenel
valentin at haenel.co
Fri Dec 26 20:08:11 EST 2014
* Eelco Hoogendoorn <hoogendoorn.eelco at gmail.com> [2014-12-13]:
> This is a general problem in trying to use JSON to send arbitrary python
> objects. Its not made for that purpose, JSON itself only supports a very
> limited grammar (only one sequence type for instance, as you noticed), so
> in general you will need to specify your own encoding/decoding for more
> complex objects you want to send over JSON.
Indeed this is a limitation of JSON.
> In the case of an object dtype, dtypestr = str(dtype) gives you a nice
> JSONable string representation, which you can convert back into a dtype
> using np.dtype(eval(dtypestr))
Yes this works fine, but doesn't work for simple dtypes like int64.
V-
More information about the NumPy-Discussion
mailing list