We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
memoryview should accept a length ndim tuple as the key of __getitem__ and __setitem__ according to memoryview
memoryview
ndim
__getitem__
__setitem__
Maybe change
- def __getitem__(self, __key: SupportsIndex) -> int: ... + def __getitem__(self, __key: SupportsIndex | tuple[SupportsIndex, ...] ) -> int: ... - def __setitem__(self, __key: SupportsIndex, __value: SupportsIndex) -> None: ... + def __setitem__(self, __key: SupportsIndex | tuple[SupportsIndex, ...], __value: SupportsIndex) -> None: ...
Example:
>>> class Foo: ... def __index__(self): ... return 0 >>> view = memoryview(bytearray(range(4))) # [0, 1, 2, 3], ndim=1 >>> print(view[Foo(),]) # getting with length 1 tuple 0 >>> view[Foo(),] = 4 # setting with length 1 tuple >>> print(view.tolist()) [4, 1, 2, 3] >>> view = view.cast("b", (2, 2)) # [[4, 1], [2, 3]], ndim=2 >>> print(view[Foo(), 1]) # getting with length 2 tuple 1 >>> view[Foo(), 1] = 5 >>> print(view.tolist()) # setting with length 2 tuple [[4, 5], [2, 3]]
The text was updated successfully, but these errors were encountered:
Makes sense to me. PR welcome!
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
memoryview
should accept a lengthndim
tuple as the key of__getitem__
and__setitem__
according to memoryviewMaybe change
Example:
The text was updated successfully, but these errors were encountered: