[Numpy-discussion] Modified header files

Paul F. Dubois paul at pfdubois.com
Wed May 9 23:12:01 EDT 2001


I have added these files to CVS. Thanks!
--Paul


-----Original Message-----
From: numpy-discussion-admin at lists.sourceforge.net
[mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Konrad
Hinsen
Sent: Wednesday, May 09, 2001 9:12 AM
To: numpy-discussion at lists.sourceforge.net
Subject: [Numpy-discussion] Modified header files


Recently we had a discussion about how to use NumPy arrays from
extension modules with multiple source files, on various platforms.
The modified header files that are attached to this message provide a
(hopefully!) general solution. In fact, I propose to make them part of
the official distribution, unless there are objections.

If used like before, these header files give exactly the same result
as the ones in NumPy 20.0.0. However, they permit to define the name
of the C API pointer array and make it globally visible. Under the
condition that the chosen name is unique, this should not create
problems under any platform, no matter if static or dynamic linking is
used.

To use NumPy features in multiple source file extension modules, you have
to write

   #define PY_ARRAY_UNIQUE_SYMBOL PyArrayXXX
   #include "Numeric/arrayobject.h"

in the main source file (the one that contains the init function) and

   #define PY_ARRAY_UNIQUE_SYMBOL PyArrayXXX
   #define NO_IMPORT_ARRAY
   #include "Numeric/arrayobject.h"

in all the others. The symbol you choose instead of PyArrayXXX should
contain both the name of the imported module (array) and the name of
the importing module (whatever your module is called) in order to be
unique with a reasonably high probability.

The same applies to the Ufunc module, just replace "array" by
"ufunc" in the example. I have also applied the "static" correction
to the Ufunc header file, there is no reason not to do it.

Konrad.
--
----------------------------------------------------------------------------
---
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
----------------------------------------------------------------------------
---





More information about the NumPy-Discussion mailing list