[Numpy-discussion] Should object arrays have a buffer interface?
Sun Dec 28 19:38:38 CST 2008
On Montag 29 Dezember 2008, Robert Kern wrote:
> On Sun, Dec 28, 2008 at 19:23, Andreas Klöckner <email@example.com>
> > Hi all,
> > I don't think PyObject pointers should be accessible via the buffer
> > interface. I'd throw an error, but maybe a (silenceable) warning would
> > do. Would have saved me some bug-hunting.
> Can you describe in more detail what problem it caused?
Well, I'm a little bit embarrassed. :) But here goes.
I have one-line MPI wrappers that build on Boost.MPI and Boost.Python. They
take a numpy array, obtain its buffer, and shove that into Boost.MPI's
isend(). My code does some sort of term evaluation, and instead of shoving the
evaluated floating point vector into MPI, it instead used the (un-evaluated)
symbolic vector, which is represented as an object array. My MPI wrapper
happily handed that object array's buffer to MPI. Oddly, instead of the
deserved segfault, I just got garbage data on the other end. (Well, some other
machine's PyObject pointers, really.)
I guess I'm wishing I would've been prevented from falling into that trap, and
I ended up wondering if there actually is a legitimate use of the buffer
interface for object arrays.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081228/c32ea965/attachment.bin
More information about the Numpy-discussion