| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
There was a problem hiding this comment.
Please add tests and What's New entry.
And I think that it is worth to support large buffers.
Sorry, something went wrong.
Documentation improvements Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
It's a more descriptive and precise name.
It's more common that the user will want a memoryview object that can be mutated. An immutable object is more rare, so make the default case return a mutable object.
|
When merging, just flatten all the commits down to a single commit. |
Sorry, something went wrong.
|
Abandoned |
Sorry, something went wrong.
No worries. Thank you for your work so far! |
Sorry, something went wrong.
|
No problem, feel free |
Sorry, something went wrong.
…tics. Improve tests and docs.
|
OK. I went back to the string_at mechanism of calling the C code via ctypes, as the conversion to c_void_p is much more flexible. |
Sorry, something went wrong.
|
Does this look interesting to you, @ZeroIntensity or @picnixz? |
Sorry, something went wrong.
|
I'll review sometime soon (today or in the next few days). |
Sorry, something went wrong.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
There was a problem hiding this comment.
Mostly LGTM
Sorry, something went wrong.
There was a problem hiding this comment.
I'm happy with this!
Sorry, something went wrong.
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
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 that refer to existing memory (e.g.
memoryview((c_byte * size).from_address(address))) but this is inefficient and the resulting memoryview object doesn't allow editing via python (invalid format errors are thrown, this is due to how ctypes objects implements the buffer protocol).
ctypes.memoryview_at() fills that gap in the API. This is similar to ffi.buffer() in the cffi module.
Fixes #112015
📚 Documentation preview 📚: https://cpython-previews--112018.org.readthedocs.build/