Skip to content

DOC: Add data= examples and async note (fix #2809) #2890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
23 changes: 23 additions & 0 deletions docs/user-guide/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ module documentation.

.. _user-guide-array:

Initializing with Data
----------------------
Pass existing data during array creation for better performance:

.. code-block:: python

import zarr
import numpy as np

data = np.random.rand(1000, 1000)
arr = zarr.create_array("data.zarr", shape=data.shape, data=data)

This provides a more concise syntax compared to separate assignment:

.. code-block:: python

# Equivalent but verbose
arr = zarr.create_array("data.zarr", shape=(1000, 1000))
arr[:] = data

.. note::
Both methods leverage async writes when using async-compatible stores like S3.

Reading and writing data
------------------------

Expand Down