We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e8b50a commit 54b3d44Copy full SHA for 54b3d44
changes/2944.misc.rst
@@ -0,0 +1 @@
1
+Avoid an unnecessary memory copy when writing Zarr to a local file
src/zarr/storage/_local.py
@@ -51,15 +51,17 @@ def _put(
51
if start is not None:
52
with path.open("r+b") as f:
53
f.seek(start)
54
- f.write(value.as_numpy_array().tobytes())
+ # write takes any object supporting the buffer protocol
55
+ f.write(value.as_numpy_array()) # type: ignore[arg-type]
56
return None
57
else:
- view = memoryview(value.as_numpy_array().tobytes())
58
+ view = memoryview(value.as_numpy_array()) # type: ignore[arg-type]
59
if exclusive:
60
mode = "xb"
61
62
mode = "wb"
63
with path.open(mode=mode) as f:
64
65
return f.write(view)
66
67
0 commit comments