[zeromq-dev] Non-copying recv

Brian Granger ellisonbg at gmail.com
Fri May 21 01:19:44 CEST 2010


Hi,

We are putting the final touches to the non-copying send/recv in the
Python bindings and I have a question about the non-copy recv.

The following will now work in a non-copying manner:

>>> msg = s.recv(copy=False)
>>> type(msg)
'Message'
>>> s2.send(msg)

But in this simple case the contents of the msg are not used in any
way by the app.  What if the app wants to use the contents of the
Message and even change it, but not make a copy?  An example would be
to pass the msg buffer to an array, which is then modified in place:

>>> msg = s.recv(copy=False)
>>> a = new_array(msg)
>>> a[0,0] = 4.0  # inplace modification

It seems like the array object would need to take ownership of the
buffer and that 0MQ couldn't deallocate the buffer.

Is this type of thing possible?  I could simple increase the 0MQ
ref-count to prevent 0MQ from freeing the message, but I am not sure
that makes sense.

Cheers,

Brian

-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com



More information about the zeromq-dev mailing list