On Thu, Jun 09, 2022 at 03:34:19PM +0100, Richard W.M. Jones wrote:
On Thu, Jun 09, 2022 at 08:34:47AM -0500, Eric Blake wrote:
> The Py_BuildValue "y#" format copies data; this is because Python
> assumes our C memory can go out of scope, while the user's python
> callback can stash off whatever bytearray object it got. But this
> copying is inefficient. Now that we already have a Python buffer-like
> object in scope for the duration of all structured reads
> (pread_structured since commit f8c76c01, aio_pread_structured since
> commit 4f15d0e9), we know that the C memory parameter to our
> chunk_callback is already (a portion of) the underlying contiguous
> memory of an original Python object. If we pass the Python callback a
> memoryview object over the correct slice of that memory, then Python
> will correctly handle the intricacies of what happens if the callback
> saves our memoryview object for later use, all without any data
> copying overhead, making use of the pread_structured form much faster.
>
Acked-by: Richard W.M. Jones <rjones(a)redhat.com>
Series is now pushed as 67dd054..8bb89d6
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization:
qemu.org |
libvirt.org