Hi Jaime On Mon, 2018-02-12 at 12:56 +0000, Jaime Fernández del Río wrote: > On Mon, Feb 12, 2018 at 12:13 PM Eugen Wintersberger <eugen.wintersbe > r...@gmail.com> wrote: > > > > > > > > > > > > > Hi there, > > > > I have a question concerning the numpy iterator C-API. I want to > > create a numpy > > > > string array using NPY_OBJECT as a datatype for creating the array > > (the reason I am going for this > > > > approach is that I do not know the length of the individual strings > > at the time I construct > > > > the array, I only know its shape). The original strings are stored > > > > I think you have the indirections wrong in dataptr?
You are absolutely right. Now everything works just as it should. Thanks a lot. > NpyIter_GetDataPtrArray returns a char**, that hold the address of > the variable where the iterator holds the address of the first byte > of the current item being iterated. > When you write to dataptr[0] you are not writing to the array, but to > where the iterator holds the address of the first byte of the current > item. > So you would have to write to dataptr[0][0], or **dataptr, to > actually affect the contents of the array. Of course, > your dataptr being a PyObject**, the compiler would probably > complaint about such an assignment. > I think that if you define dataptr as a PyObject*** (yay, three star > programming!) and then assign to **dataptr, everything will work > fine. If that doesn't work, maybe try to make dataptr a char**, and > then assign to (PyObject *)(**dataptr) = ... > Jaime > > > Thanks in advance. > > > > > > > > best regards > > > > Eugen > > > > > > _______________________________________________ > > > > NumPy-Discussion mailing list > > > > NumPy-Discussion@python.org > > > > https://mail.python.org/mailman/listinfo/numpy-discussion > > > > > > > -- > (\__/) > ( O.o) > ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus > planes de dominación mundial. > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion