Robert Bradshaw wrote:
> On Apr 28, 2009, at 11:01 AM, Robert Kern wrote:
> 
>> On 2009-04-28 01:05, Dag Sverre Seljebotn wrote:
>> [Mike Fletcher wrote:]
>>>>      * You have to call import_array() in your module or many of the
>>>>        Numpy C API entry points will segfault
>>> Are you sure about this? I never do it. I know you need to do it  
>>> from C
>>> code, but is it not enough in Cython to do
>>>
>>> import numpy
>>>
>>> ?
>> If you call any of the PyArray_* functions, you will need an  
>> import_array()
>> call. That does not just import numpy; it sets up the function  
>> pointer table in
>> your extension module such that the PyArray_* #defines reference  
>> the right
>> functions.
> 
> So "import numpy" doesn't call import_array() then?

Apparently a plain import it does what is needed for normal/trivial 
usage of NumPy/Cython, but if you in addition need to call low-level 
PyArray_*-functions then you need the call.

This is fairly well documented in the NumPy API, and my tutorial doesn't 
mention PyArray_*-functions, so I consider the issue OK. (Though we 
could certainly have additional documentation on the wiki for using the 
lower-level NumPy API from Cython).

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to