How to specific multiple dtypes in numpy.ndarray?

lampahome pahome.chen at mirlab.org
Thu Dec 19 05:52:10 EST 2019


I meet performance is low when I use struct.unpack to unpack binary data.

So I tried to use numpy.ndarray
But meet error when I want to unpack multiple dtypes

Can anyone teach me~

Code like below:
# python3
import struct
import numpy as np
s1 = struct.Struct("@QIQ")
ss1 = s1.pack(1,11,111)
np.ndarray((3,), [('Q','I','Q')], ss1)
# ValueError: mismatch in size of old and new data-descriptor.


More information about the Python-list mailing list