Skip to content
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

Virtually implement __buffer__ for Python <3.12 to support typing #26783 #26784

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Andrej730
Copy link
Contributor

@Andrej730 Andrej730 commented Jun 22, 2024

See #26783 for the details

Note that there is also __release_buffer__ part of the buffer protocol -

numpy/numpy/__init__.pyi

Lines 2843 to 2844 in 7687245

if sys.version_info >= (3, 12):
def __release_buffer__(self, buffer: memoryview, /) -> None: ...

I've kept it Python 3.12+ only as it's optional part of the protocol and it's Buffer is using just __buffer__ to detect whether class supports the protocol. So, there is no need to virtually implement it for <3.12.
image

@Andrej730 Andrej730 changed the title Virtually implement __buffer__ for Python <3.11 to support typing #26783 Virtually implement __buffer__ for Python <3.12 to support typing #26783 Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Awaiting a code review
Development

Successfully merging this pull request may close these issues.

None yet

1 participant