Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/3368.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Improved performance of reading arrays by not unnecessarily using
the fill value.
5 changes: 5 additions & 0 deletions src/zarr/abc/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ async def read(
The second slice selection determines where in the output array the chunk data will be written.
The ByteGetter is used to fetch the necessary bytes.
The chunk spec contains information about the construction of an array from the bytes.

If the Store returns ``None`` for a chunk, then the chunk was not
written and the implementation must set the values of that chunk (or
``out``) to the fill value for the array.

out : NDBuffer
"""
...
Expand Down
6 changes: 2 additions & 4 deletions src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,10 @@ async def _decode_single(
)

# setup output array
out = chunk_spec.prototype.nd_buffer.create(
out = chunk_spec.prototype.nd_buffer.empty(
shape=shard_shape,
dtype=shard_spec.dtype.to_native_dtype(),
order=shard_spec.order,
fill_value=0,
)
shard_dict = await _ShardReader.from_bytes(shard_bytes, self, chunks_per_shard)

Expand Down Expand Up @@ -498,11 +497,10 @@ async def _decode_partial_single(
)

# setup output array
out = shard_spec.prototype.nd_buffer.create(
out = shard_spec.prototype.nd_buffer.empty(
shape=indexer.shape,
dtype=shard_spec.dtype.to_native_dtype(),
order=shard_spec.order,
fill_value=0,
)

indexed_chunks = list(indexer)
Expand Down
3 changes: 1 addition & 2 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1349,11 +1349,10 @@ async def _get_selection(
f"shape of out argument doesn't match. Expected {indexer.shape}, got {out.shape}"
)
else:
out_buffer = prototype.nd_buffer.create(
out_buffer = prototype.nd_buffer.empty(
shape=indexer.shape,
dtype=out_dtype,
order=self.order,
fill_value=self.metadata.fill_value,
)
if product(indexer.shape) > 0:
# need to use the order from the metadata for v2
Expand Down
Loading