Subsections

10.1 Accessing the numarray C-API

There's a couple things you need to do in order to access numarray's C-API in your own C extension module:

10.1.1 include numarray.h

Near the top of your extension module add the line:

#include "numarray.h"
This gives your C-code access to the numarray typedefs, macros, and function prototypes.

10.1.2 import libnumarray

In your extension module's initialization function, add the line:

  import_libnumarray();

import_libnumarray() is actually a macro which sets up a pointer to the numarray C-API jump table. If you forget to call import_libnumarray(), your extension module will crash as soon as you call a numarray API function, because your application will attempt to dereference a NULL pointer.

Note that there is also a Numeric compatible API which substitutes arrayobject.h for numarray.h and import_array() for import_libnumarray() respectively.

Send comments to the NumArray community.