Re: [Numpy-discussion] NumPy C API question

2014-05-22 Thread Stefan Seefeld
Hi Nathaniel, On 2014-05-21 20:15, Nathaniel Smith wrote: > Hi Stefan, > > One possibility that comes to mind: you may want in any case some way > to temporarily "pin" an object's memory in place (e.g., to prevent one > thread trying to migrate it while some other thread is working on it). > If so

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Nathaniel Smith
Hi Stefan, One possibility that comes to mind: you may want in any case some way to temporarily "pin" an object's memory in place (e.g., to prevent one thread trying to migrate it while some other thread is working on it). If so then the Python wrapper could acquire a pin when the ndarray is alloc

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Stefan Seefeld
Hi Nathaniel, thanks for the prompt and thorough answer. You are entirely right, I hadn't thought things through properly, so let me back up a bit. I want to provide Python bindings to a C++ library I'm writing, which is based on vector/matrix/tensor data types. In my naive view I would expose th

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Nathaniel Smith
Hi Stefan, Allocating a new PyArrayObject isn't terribly expensive (compared to all the other allocations that Python programs are constantly doing), but I'm afraid you have a more fundamental problem. The reason there is no supported API to change the storage pointer of a PyArrayObject is that th

[Numpy-discussion] NumPy C API question

2014-05-21 Thread Stefan Seefeld
Hello, I would like to expose an existing (C++) object as a NumPy array to Python. Right now I'm using PyArray_New, passing the pointer to my object's storage. It now happens that the storage point of my object may change over its lifetime, so I'd like to change the pointer that is used in the PyA