[Numpy-discussion] Updating cython directory to pxd usage: objections?

Robert Kern robert.kern@gmail....
Fri Jun 20 14:23:37 CDT 2008

On Fri, Jun 20, 2008 at 14:11, Matthew Brett <matthew.brett@gmail.com> wrote:
> Hi,
> As a matter of interest, what is the relationship, if any, between (in Cython)
> import numpy
> and
> cnp.import_array()
> Are they initializing different copies of the same thing?

No. "import numpy" is essentially the same as the pure Python
equivalent; it loads the module and puts it into the namespace.
cnp.import_array() loads the module (or reuses the already loaded
one), does not put it into any namespace, but then, most importantly,
grabs the pointer to the table of function pointers and assigns it to
the local void** variable. All of the numpy API is made available to
third-party extension modules by #define macros which look up into
this table.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco

More information about the Numpy-discussion mailing list