Skip to content

Conversation

rianhunter
Copy link
Contributor

@rianhunter rianhunter commented Nov 13, 2023

gh-112015:

ctypes currently has no way to easily create a buffer object from a pointer and a dynamic size. It is possible to create memoryview objects of array objects (e.g.
memoryview((c_ubyte * 10)())) but this is excessively slow when implementing a callback function in Python that is passed a dynamic void * and a size_t.

ctypes.buffer_at() fills that gap in the API. This is similar to ffi.buffer() in the cffi module.


📚 Documentation preview 📚: https://cpython-previews--112016.org.readthedocs.build/

ctypes currently has no way to easily create a buffer object
from a pointer and a dynamic size. It is possible to create
memoryview objects of array objects (e.g.
memoryview((c_ubyte * 10)())) but this is excessively slow when
implementing a callback function in Python that is passed a
dynamic void * and a size_t.

`ctypes.buffer_at()` fills that gap in the API. This is similar
to `ffi.buffer()` in the cffi module.
@bedevere-app
Copy link

bedevere-app bot commented Nov 13, 2023

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@rianhunter rianhunter closed this Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant