I'm currently using the C/Python API to read data from a large binary file.
This result in Python is not as efficient as the pure C result (time x2) because, I think, of the time took to wrap things up into a PyObject. Typically, I store 42-elements tuples in a PyArrayObject. To do this, I use:
PyObject *r = Py_BuildValue("(f, I, i, K, f, K, K, etc..)", a, b, c, etc...) ;
My question is the following: Is there a more efficient way to do it (quicker execution time)?
For example: will PyTuple_Pack(n, args) do it more quickly ?
For time critical code, I create a tuple of the desired length and then create the components individually and stuff them into the tuple.
C/Python API : efficiency of Py_BuildValue use