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

Support PEP688 for buffers and in particular numpy array #188

Closed
tonybaloney opened this issue Sep 5, 2024 · 0 comments · Fixed by #187
Closed

Support PEP688 for buffers and in particular numpy array #188

tonybaloney opened this issue Sep 5, 2024 · 0 comments · Fixed by #187

Comments

@tonybaloney
Copy link
Owner

The buffer protocol offers a lower-level interface to access the contents of a buffer structure like bytearray, array.array and numpy's ndarray.

The C API for this protocol is defined in
https://docs.python.org/3/c-api/buffer.html

Typing support came in 3.12 for collections.abc.Buffer but is available in typing_extensions.Buffer. Neither are generic, although numpy has a typing extension, none of those generics are suitable https://numpy.org/devdocs/reference/typing.html#numpy.typing.ArrayLike

We need to:

  • Detect a 'Buffer' as a result type
  • Have an API for creating a buffer from a PyObject
  • Have an API for yeilding data from that buffer
  • Release the buffer safely

I think this would provide a faster interface for getting data out of large numpy arrays rather than using .tolist()

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 a pull request may close this issue.

1 participant