[Libguestfs] [PATCH nbdkit 2/2] python: More precise Python parameter passing

Richard W.M. Jones rjones at redhat.com
Tue Dec 21 22:24:10 UTC 2021


On Wed, Dec 22, 2021 at 12:03:44AM +0200, Nir Soffer wrote:
> This is not needed. I think the accepted way to pass boolean values
> to python is "i". Internally python True and False are 1 and 0, and
> you can use them as such:

The documentation suggests "p" for bools:

https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue

But that's not relevant for the patch because:

...
> However PyObject_CallFunctionObjArgs is more efficient than
> PyObject_CallFunction
> so this looks good.

Indeed.

> 0x10_0000_0000 is very confusing, why not 64 * GiB?
> 
> For the zero count, should we use 2**32 - 1 to make sure zero
> works with the maximum count?

Is "GiB" defined somewhere?

>>> print(GiB)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'GiB' is not defined

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list