[Numpy-discussion] How to call import_array() properly?

Bruce Sherwood Bruce_Sherwood at ncsu.edu
Mon Dec 27 13:09:57 EST 2010

Thanks for the good suggestion. I now see that it was purely
historical that import_array was driven (indirectly through
init_numpy) from the pure Python component of the module rather than
in the import of the C++ component, and I've changed that. However,
I'm still curious as to whether there's a more intelligent or elegant
way to drive import_array than the following code:


Bruce Sherwood

On Mon, Dec 27, 2010 at 8:20 AM, Robert Kern <robert.kern at gmail.com> wrote:
> On Sun, Dec 26, 2010 at 17:26, Bruce Sherwood <Bruce_Sherwood at ncsu.edu> wrote:
>> In my Python code I have
>> import cvisual
>> cvisual.init_numpy()
>> and in my C++ code I have
>> void
>> init_numpy()
>> {
>>    import_array();
>> }
> The import_array() call goes into the initialization function for your
> module, e.g. initcvisual(). Do not put it into a separate function for
> the user of your module to call.
> --
> 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
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

More information about the NumPy-Discussion mailing list