[Numpy-discussion] python numpy code many times slower than c++

Sturla Molden sturla@molden...
Wed Jan 21 07:45:36 CST 2009

On 1/21/2009 2:38 PM, Sturla Molden wrote:

> If you can get a pointer (as integer) to your C++ data, and the shape 
> and dtype is known, you may use this (rather unsafe) 'fromaddress' hack:

And opposite, if you need to get the address referenced to by an 
ndarray, you can do this:

def addressof(array):
    return arr.__array_interface__['data'][0]

Then you will have to cast this unsigned integer to a pointer type in 
C++. Note that arr.data returns a buffer.

Sturla Molden

More information about the Numpy-discussion mailing list