Skip to content

Array protocol - #487

Merged
FrancescAlted merged 7 commits into
mainfrom
array-protocol
Sep 30, 2025
Merged

FrancescAlted merged 7 commits into
mainfrom
array-protocol

Conversation

@FrancescAlted

@FrancescAlted FrancescAlted commented Sep 29, 2025 •

Copy link
Copy Markdown
Member

This adds a new Array protocol that is useful to describe the minimal interface that should be supported for blosc2 functions to deal with array inputs. This protocol is really minimal, and it does not actually depend on any non-standard array API method or property (like .chunks); @lshaw8317 hope this is fine for most (if not all) the signature changes proposed here, but if not, we need to discuss which cases require a more complete interface (blosc2.ChunkedArray ?).

So instead of describing the input types as e.g. NDArray | NDField | C2Array | LazyArray, they are described now as blosc2.Array.

As a plus, and thanks to the @runtime_checkable decorator, compliance with the new Array protocol can be tested at runtime with isinstance(object, blosc2.Array).

Comment thread src/blosc2/lazyexpr.py Outdated
Comment thread src/blosc2/lazyexpr.py Outdated
Comment thread src/blosc2/ndarray.py Outdated
@FrancescAlted
FrancescAlted merged commit 98ba424 into main Sep 30, 2025
13 checks passed
@lshaw8317
lshaw8317 deleted the array-protocol branch October 14, 2025 11:20
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.

2 participants