Re: [Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-03-04 Thread Dag Sverre Seljebotn
Wes McKinney wrote: > This still doesn't explain why the buffer interface was slow. I finally remembered to look at this; there seems to be a problem in your code: > def reindexObject(ndarray[object, ndim=1] index, > ndarray[object, ndim=1] arr, > dict idxMap):

Re: [Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-02-12 Thread Dag Sverre Seljebotn
Wes McKinney wrote: > > The general problem here is an indexed array (by dates or strings, for > example), that you want to conform to a new index. The arrays most of > the time contain floats but occasionally PyObjects. For some reason > the access and assignment is slow (this function can be f

Re: [Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-02-11 Thread Wes McKinney
I actually got it to work-- the function prototype in the pxi file was wrong, needed to be: int PyArray_SETITEM(object obj, void* itemptr, object item) This still doesn't explain why the buffer interface was slow. The general problem here is an indexed array (by dates or strings, for example), t

Re: [Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-02-11 Thread Dag Sverre Seljebotn
Wes McKinney wrote: > I am writing some Cython code and have noted that the buffer interface > offers very little speedup for PyObject arrays. In trying to rewrite the > same code using the C API in Cython, I find I can't get PyArray_SETITEM to > work, in a call like: > > PyArray_SETITEM(result, i

Re: [Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-02-11 Thread Hanni Ali
Hi Wes, I do not profess to be an expert, but I have been off loading a fair number of loops to C from Python code and achieved significant improvements most have been of the following form (which I have found to be the fastest): size = *incomingArrayObj->dimensions; r_dptr = PyArray_DATA(result

[Numpy-discussion] PyArray_SETITEM with object arrays in Cython

2009-02-11 Thread Wes McKinney
Hello, I am writing some Cython code and have noted that the buffer interface offers very little speedup for PyObject arrays. In trying to rewrite the same code using the C API in Cython, I find I can't get PyArray_SETITEM to work, in a call like: PyArray_SETITEM(result, iterresult.dataptr, obj)