Skip to content

Commit 68a7d56

Browse files
committed
DOC: Add data= examples and async note (fix #2809)
1 parent ee60792 commit 68a7d56

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/user-guide/arrays.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ module documentation.
3030

3131
.. _user-guide-array:
3232

33+
Initializing with Data
34+
---------------------
35+
Pass existing data during array creation for better performance:
36+
37+
.. code-block:: python
38+
39+
import zarr
40+
import numpy as np
41+
42+
data = np.random.rand(1000, 1000)
43+
arr = zarr.create_array("data.zarr", shape=data.shape, data=data)
44+
45+
This avoids a separate write step and is more efficient than:
46+
47+
.. code-block:: python
48+
49+
# Less efficient approach
50+
arr = zarr.create_array("data.zarr", shape=(1000, 1000))
51+
arr[:] = data
52+
53+
.. note::
54+
For cloud stores like S3, use ``data=`` with async writes for best performance.
55+
3356
Reading and writing data
3457
------------------------
3558

0 commit comments

Comments
 (0)