Python binding APIs strict or loose

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






           Hi

There is a question. we need strict python binding API or loose one.

                For example:
The setSchedulerParameters(), it accepts one of parameters: 'vcpu_quota' In C its type is of 'long long', then we need a conversion from PyInt/PyLong to 'long long' by using cpython function 'PyLong_AsLongLong'. The problem is when the user python pass in a value of type Pyfloat instead of PyInt/PyLong, the cpython function drops the fraction part of the value automatically, Is it what we want or we need to add a type checking to ensure that the type of value passed in is PyInt/PyLong, otherwise, we raise an exception.

>> dom.schedulerParameters()
{'vcpu_quota': -1L, 'vcpu_period': 100000L, 'cpu_shares': 500L}

>> dom.setSchedulerParameters({'vcpu_quota': 10.88})
                works as dom.setSchedulerParameters({'vcpu_quota': 10})

                Any idea?

                Guannan Ren

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]