Skip to content

Commit 29508cf

Browse files
committed
(fix): add comment and check
1 parent 9eac892 commit 29508cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/zarr/core/buffer/cpu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ def create(
154154
order: Literal["C", "F"] = "C",
155155
fill_value: Any | None = None,
156156
) -> Self:
157-
if fill_value is None or fill_value == 0:
157+
# np.zeros is much faster than np.full, and therefore using it when possible is better.
158+
if fill_value is None or (isinstance(fill_value, int) and fill_value == 0):
158159
return cls(np.zeros(shape=tuple(shape), dtype=dtype, order=order))
159160
else:
160161
return cls(np.full(shape=tuple(shape), fill_value=fill_value, dtype=dtype, order=order))

0 commit comments

Comments
 (0)