Skip to content

perf: cache default ArraySpec for regular chunk grids#3908

Open
d-v-b wants to merge 3 commits intozarr-developers:mainfrom
d-v-b:perf/cache-default-chunk-spec
Open

perf: cache default ArraySpec for regular chunk grids#3908
d-v-b wants to merge 3 commits intozarr-developers:mainfrom
d-v-b:perf/cache-default-chunk-spec

Conversation

@d-v-b
Copy link
Copy Markdown
Contributor

@d-v-b d-v-b commented Apr 15, 2026

For regular grids, all chunks have the same codec_shape, so we can
build the ArraySpec once and reuse it for every chunk — avoiding the
per-chunk ChunkGrid.getitem + ArraySpec construction overhead.

Adds _get_default_chunk_spec() and uses it in _get_selection and
_set_selection. Saves ~5ms per 1000 chunks.

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

For regular grids, all chunks have the same codec_shape, so we can
build the ArraySpec once and reuse it for every chunk — avoiding the
per-chunk ChunkGrid.__getitem__ + ArraySpec construction overhead.

Adds _get_default_chunk_spec() and uses it in _get_selection and
_set_selection. Saves ~5ms per 1000 chunks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions bot added the needs release notes Automatically applied to PRs which haven't added release notes label Apr 15, 2026
@github-actions github-actions bot removed the needs release notes Automatically applied to PRs which haven't added release notes label Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.09%. Comparing base (2fbd30a) to head (ca901f8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3908   +/-   ##
=======================================
  Coverage   93.08%   93.09%           
=======================================
  Files          85       85           
  Lines       11230    11236    +6     
=======================================
+ Hits        10454    10460    +6     
  Misses        776      776           
Files with missing lines Coverage Δ
src/zarr/core/array.py 97.82% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant