Python type equivalent of a c list


I have to call from python a C macro which uses as an input a pointer which is used as a list in c.
When I try to call it with a float list argument, I get a “could not convert argument 1” error.

C code :

float myMacro(*float myList)
{return myList[1]}

Python code:

  • Import the macro as r.myMacro using LoadMacro
  • Define my_list a list of python or numpy floats (both fail)


Output :

TypeError: float* myList -> could not convert argument 1

I also tried with a tuple and it failed.
Thanks in advance for your help


did you try with an array?


Yeah, sorry I forgot to mention it but it was my first try.

Did you try it with an array that is specifically a float32 array? Because otherwise it becomes a float64 on my machine, which would be a double in C++:

>>> import numpy as np
>>> x = np.array([1., 2., 3. ])
>>> x.dtype
>>> y = np.array([1., 2., 3. ], dtype='float32')
>>> y.dtype

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.