[zeromq-dev] Fwd: Re: New Python bindings

Jon Dyte jon at totient.co.uk
Sun Feb 14 15:59:59 CET 2010


meant to put this on the list as well.

jon

----------  Forwarded Message  ----------

Subject: Re: [zeromq-dev] New Python bindings
Date: Sunday 14 Feb 2010
From: Jon Dyte <jon at totient.co.uk>
To: ellisonbg at gmail.com

On Friday 12 Feb 2010, Brian Granger wrote:
> Hello all,
> 
> Over the last day I have redone the Python bindings from scratch.  The
> overall design is the same, but I have used Cython, which will make
> the bindings easier to develop/maintain and more flexible in the long
> run.  Here is my github repo for this:
> 
> http://github.com/ellisonbg/pyzmq
> 
> Some highlights of what I have done so far:
> 
> * Cython (http://www.cython.org) based.  Cython is not a requirement
> for using this, only
> for developers.
> * Improved performance.  For small msg sizes, the performance is the
> same as the previous Python bindings, but for larger message sizes,
> the latency and throughput
> benchmarks are better.  The main improvement is that on sends I am not
> doing a memcpy
> to copy the Python string to the msg struct.  The msg struct simply
> uses the same buffer
> that the Python str object is using.


Is this is safe? After calling send, the msg is passed to an IO thread ?

That means there are now two threads concerned with the lifetime of memory
of the string (python and the zmq io thread?)

I see you call zmq_msg_init_data with NULL for the free function, but there is
still the case that the python thread could destroy the string before the io 
thread uses it? I would expect you to have to pass a free function, 
and manipulate the string in send to increase the refcount, and the free 
function to decrease the refcount. 

Caveat: I havent ever used Cython before, but have used SIP which is used to 
(Wrap Qt for PyQt) for my own C++.

cheers

jon




> * Better error handling.
> * A build system (setup.py) that is standalone and a bit more configurable.
> * New send_json/revc_json and send_pyobj/recv_pyobj methods of Socket that
> allow you to send Python objects as messages using Python's pickle
> serialization or json.
> 
> The only part of the API that I have not wrapped is zmq_poll.  This is
> next on my list.  But first, I want to understand the design of
> zmq_poll a bit better.  I have started a thread to discuss those
> things.
> 
> I have licensed this code as LGLP and am fine with it being pulled
> into the main zeromq repo if that is wanted.
> 
> 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
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> 



-------------------------------------------------------



More information about the zeromq-dev mailing list