[Numpy-discussion] C-extension -- how do I accept a vector of both type double and type int?
zyzhu2000 at gmail.com
Thu Jul 26 21:14:46 EDT 2007
On 7/26/07, Robert Kern <robert.kern at gmail.com> wrote:
> Geoffrey Zhu wrote:
> >>>>> How do I handle this situation? Is there any way to access any data
> >>>>> type that can be converted into a double?
> >>>> I usually use PyArray_FROM_OTF(). That handles the usual cases. It's pretty much
> >>>> like starting off a pure Python function with asarray(x, dtype=whatever).
> >>> That is going to make a copy of the memory every time and might slow
> >>> down things a lot?
> >> Not if you pass it an array with the requested properties.
> > Neat. Do you know if PyArray_FROM_OTF() increments the reference count
> > of the returned object? The documentation does not say. My guess is
> > yes.
This is probably off the topic. Do you know such a function for
regular python objects? For example, I know a PyObject is a number,
but I don't know the exact type. Is there any quick way to convert it
to a C double type?
More information about the NumPy-Discussion