[Numpy-discussion] Porting to the new C-API (1.7)

Mads Ipsen mads.ipsen at gmail.com
Mon Oct 21 03:20:12 EDT 2013


Hi,

I've been using the numpy-1.6 C-API as part of a large C++ based OpenGL
application.

The C++ classes are exposed in Python by using SWIG, and utilize numpy
arrays both as inputs to methods and method return values to the Python
caller.

To enable numpy in the SWIG generated Python module, the SWIG generated
C++ file define

  #define PY_ARRAY_UNIQUE_SYMBOL PyArray_API

whereas all other C++ files that need access to the numpy C-API contain

  #define NO_IMPORT_ARRAY
  #include "numpy/arrayobject.h"

I have now updated to numpy-1.7, and receive warnings of the form

#warning "Using deprecated NumPy API, disable it by
#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION"

This is basically fine with me, and I don't mind doing an update of my
code to the new C-API.

I have a few questions though:

1) Since I am apparently using the old API, where can I find a list of
   the deprecated things I use? That would make the upgrade easier.

2) Do I still have to use the PY_ARRAY_UNIQUE_SYMBOL approach when
   using the new C-API.

3) According to some websites you can do something like

  #define PY_ARRAY_UNIQUE_SYMBOL PyArrayXXX

This puzzles me a bit. Is there a doc somewhere where this whole thing
is explained in detail. I must admit, its somewhat hard to grasp
what's going on.

Best regards,

Mads

-- 
+-----------------------------------------------------+
| Mads Ipsen                                          |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv |                              |
| DK-2500 Valby        | phone:          +45-29716388 |
| Denmark              | email:  mads.ipsen at gmail.com |
+----------------------+------------------------------+




More information about the NumPy-Discussion mailing list