NumPy: 3-byte, 6-byte types (aka uint24, uint48)
问题 NumPy seems to lack built-in support for 3-byte and 6-byte types, aka uint24 and uint48 . I have a large data set using these types and want to feed it to numpy. What I currently do (for uint24): import numpy as np dt = np.dtype([('head', '<u2'), ('data', '<u2', (3,))]) # I would like to be able to write # dt = np.dtype([('head', '<u2'), ('data', '<u3', (2,))]) # dt = np.dtype([('head', '<u2'), ('data', '<u6')]) a = np.memmap("filename", mode='r', dtype=dt) # convert 3 x 2byte data to 2 x