[Numpy-discussion] newbie for writing numpy/scipy extensions

David M. Cooke cookedm at physics.mcmaster.ca
Thu Apr 27 11:32:11 CDT 2006

Gennan Chen <gnchen at cortechs.net> writes:

> Hi! All,
> I just start writing my own python extension based on numpy. Couple
> of questions here:
> 1. I have some utility functions, such as wrappers for
> PyArray_GETPTR* needed be access by different extension modules. So,
> I put them in utlis.h and utlis.c. In utils.h, I need to include
> "numpy/arrayobject.h". But the compilation failed when I include it
> again in my extension module function, wrap.c:
> #include "numpy/arrayobject.h"
> #include "utils.h"
> When I remove it and use
> #include "utils.h"
> the compilation works. So, is it true that I can only include
> arrayobject.h once?

What is the compiler error message?

> 2.  which import I should use in my initial function:
> import_array()

This one. It's the one to use for Numeric, numarray, and numpy.

> or
> import_libnumarray()

This is for numarray, the other Numeric derivative. It pulls in the
numarray-specific stuff IIRC.

|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca

More information about the Numpy-discussion mailing list