> Hi all, > > I've spent the day writing a Numpy format handler in Cython and thought > there were a few things that the Cython numpy tutorial possibly should > cover:
Are you talking about wiki.cython.org/tutorials/numpy? I think that's targeted to a a different audience who don't immedeately feel comfortable calling the NumPy C API... > * Numpy dtype references appear to be normally "borrowed" references > in the C API, so when you call numpy array functions that take a > dtype you need to Py_INCREF the dtype first, this will show up as > complaints from numpy that you're trying to delete the dtype objects Good point. > * You have to call import_array() in your module or many of the > Numpy C API entry points will segfault Are you sure about this? I never do it. I know you need to do it from C code, but is it not enough in Cython to do import numpy ? Did you actually get a segfault using Cython? Could you send me an example? I'd really like to make this automatic somehow. > Anyway, not sure if or where such changes should go, but just thought it > might help others. I you feel it fits within the tutorial feel free to add it there, otherwise you can always create a sub-page about "Using the NumPy C API" or somesuch. Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
