You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reading 0-d fixed-length bytes arrays (|S<n>) is ~2.5x slower than equally sized uint8 arrays #4464
Reading a scalar (0-d) fixed-length bytes array, as commonly used in zarr format v2 data to store
encoded blobs (e.g. JPEG/PNG images), is significantly slower than reading the same number of bytes from a
1-d uint8 array:
0-d |S1000000 blob[()] 1809.7 us
1-d uint8 u8[...] 739.8 us
(zarr-python 2.18 reads the same 0-d array in ~20 us + I/O)
Profiling shows the time is spent copying the payload multiple times: CpuNDBuffer.__getitem__ (np.asanyarray(self._data.__getitem__(key))), CpuNDBuffer.__setitem__ into the
output buffer, and NDBuffer.as_scalar() (self.as_numpy_array()[()]). For a 0-d fixed-length bytes dtype each of
these creates a new copy of the full item.
A fast path for complete chunk reads of 0-d arrays (returning the decoded chunk directly instead of copying it into a
freshly allocated output buffer) would likely remove most of this overhead.
Activity
d-v-b commentedon Oct 1, 2026
thanks for the report and sorry for the regression. your patch idea looks good
janickm commentedon Oct 2, 2026
ok great - let me draft a PR for this then
docs: link the 0-d fixed-length bytes entry to its pull request
docs: 3.4.1 release notes
docs: 3.4.1 release notes
docs: 3.4.1 release notes (#4489)