Skip to content

Implement ctypes.buffer_at() #112016

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

Closed
wants to merge 1 commit into from
Closed

Implement ctypes.buffer_at() #112016

wants to merge 1 commit into from

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