[Pyrex] Convert tuple/list in primitive*

Charles Moad cmoad at indiana.edu
Thu Dec 16 16:21:54 CET 2004


Probably another case of being answered before, but I can't find
anything.  Given something simple like:

cdef extern c_setParam3fv "setParam3fv"(int param, float *value)

def setParam3fv(param, value):
   cdef float args[3]
   cdef int i

   i = 0
   for val in value:
      args[i] = val
   c_setParam3fv(param, args)

This works fine and all, but I don't think this is my preferred way
given a large list of floats since the python looping contruct is slow.

Is there a memcpy type trick I can do, or possibly a cast?

Thanks,

-- 
Charles Moad <cmoad at indiana.edu>




More information about the Pyrex mailing list