Wrap Numpy with Cython?

Robert Kern robert.kern at gmail.com
Tue Jun 24 22:09:48 CEST 2008


martin.nordstrom87 at gmail.com wrote:
> Hi! I'm trying to wrap numpy with Cython and I've tried to use this
> guide to manage this: http://wiki.cython.org/WrappingNumpy
> However when I send an array to mysum() it gives me the right answer
> only when dtype of the array is float, otherwise it gives me random
> answers. The problem may be that the array is converted to a C double
> which is just as long as float for Numpyarrays and therefore it works
> only when the dtype is float. How do I make a Numpywrapper that works
> with an arbitrary dtype?

You will need a Cython function for each dtype and dispatch based on the dtype.

You will want to ask further numpy questions on the numpy mailing list:

   http://www.scipy.org/Mailing_Lists

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list