[Numpy-discussion] Updating cython directory to pxd usage: objections?
Sat Jun 21 18:06:13 CDT 2008
On Sat, Jun 21, 2008 at 15:49, Stéfan van der Walt <email@example.com> wrote:
> 2008/6/20 Robert Kern <firstname.lastname@example.org>:
>>> 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.
> Since "import numpy" already sets up the pointer table, is it then
> necessary to use import_array?
None of the third party extension modules have a reference to it.
import_array() grabs the pointer to the start of the pointer table and
assigns it to a void** variable *local* to the extension module. Each
extension module has its own and needs it to be set up via
import_array(). "import numpy" sets up the table, but does not expose
it. import_array() does not set up the table itself, but rather
exposes it to the extension module.
"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