We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9eac892 commit 29508cfCopy full SHA for 29508cf
src/zarr/core/buffer/cpu.py
@@ -154,7 +154,8 @@ def create(
154
order: Literal["C", "F"] = "C",
155
fill_value: Any | None = None,
156
) -> Self:
157
- if fill_value is None or fill_value == 0:
+ # 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):
159
return cls(np.zeros(shape=tuple(shape), dtype=dtype, order=order))
160
else:
161
return cls(np.full(shape=tuple(shape), fill_value=fill_value, dtype=dtype, order=order))
0 commit comments