rogersce / cnpy

library to read/write .npy and .npz files in C/C++
MIT License
1.31k stars 300 forks source link

Fix a mis-parse of NPY v2.0 and 3.0 headers #77

Open nmcclatchey opened 3 years ago

nmcclatchey commented 3 years ago

CNPY originally only supported NPY 1.0 headers, with a 2-byte length field. This PR causes parse_npy_header() to respond to NPY 2.0 and 3.0 by reading the header length as 4 bytes.

AtomicVar commented 2 years ago

I only saw version 2.0 from NEP 1, can you tell me where is version 3.0 defined? Thanks.

nmcclatchey commented 2 years ago

You can find all 3 versions defined on numpy.org. Specifically, on the numpy.lib.format page.

Version 3.0 merely swaps ASCII strings to Unicode strings.