[Libguestfs] [PATCH nbdkit 1/2] python: For v2 API, avoid copy by passing a buffer to pread.

Eric Blake eblake at redhat.com
Mon Nov 25 23:37:43 UTC 2019


On 11/25/19 7:17 AM, Richard W.M. Jones wrote:
> It's more efficient if we pass the C buffer directly to Python code.
> In some cases the Python code will be able to write directly into the
> C buffer using functions like file.readinto and socket.recv_into.
> This avoids an extra copy.
> 
> Thanks: Nir Soffer
> ---
>   plugins/python/example.py               |  8 ++++---
>   plugins/python/nbdkit-python-plugin.pod | 16 +++++--------
>   plugins/python/python.c                 | 32 +++++++++++++++----------
>   tests/python-exception.py               |  4 ++--
>   tests/shebang.py                        |  5 ++--
>   5 files changed, 36 insertions(+), 29 deletions(-)

Hmm, my counterproposal that adds kwarg parameters without requiring 
API_VERSION makes it impossible to make this sort of switch.  So this 
alone is a good reason why a clean break in python plugins opting in to 
API_VERSION 1 or 2 makes sense (and maybe we still want v2 to use 
keywords instead of positional parameters, but with less impact to v1 
clients).

As I said with my counterproposal, now is the time to decide what we 
like best out of both proposals, and probably another round of churn on 
what our final interface will be.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list