[zeromq-dev] pyczmq and ctx.set_linger()

MinRK benjaminrk at gmail.com
Fri Jan 17 17:49:10 CET 2014


On Fri, Jan 17, 2014 at 8:12 AM, Michel Pelletier <
pelletier.michel at gmail.com> wrote:

> On Fri, Jan 17, 2014 at 6:34 AM, Greg Ward <greg at gerg.ca> wrote:
>
>> On 17 January 2014, Pieter Hintjens said:
>> > On Thu, Jan 16, 2014 at 9:01 PM, Michel Pelletier
>> > <pelletier.michel at gmail.com> wrote:
>> >
>> > > Yes, pyczmq is very much a literal 1 to 1 wrapper around the czmq C
>> > > interface.
>> > >
>> > > Note that there is also an "object oriented" interface:
>> >
>> > CZMQ was designed to allow an OO interface on top; it may not succeed
>> > in all classes. Where it's possible I'd probably not expose the 1-1
>> > wrapper at all, and only provide the proper OO interface. (Less
>> > confusing for users, maybe?)
>>
>> Having played around with pyczmq a little bit for a few hours, I'm
>> starting to wonder if that's really the right way to wrap CZMQ. My two
>> concerns are 1) import-time overhead
>
>
> This seems like an un-problem to me.  cffi parses the function
> declarations on import, that takes a small amount time.  You pay that small
> price once.
>
>
>> and 2) the C-style interface (not
>> OO, un-Pythonic).
>>
>
> As I pointed out there is an "OO" interface.  Maybe it's the Lisper in me
> talking, but... they're just functions.  They take arguments.  You call
> them.  It's seems pretty straightforward and "Pythonic" to me.
>
>
>> I note that pyzmq already solves both of these problems: it's much
>> faster to import than pyczmq, and it exposes a nice Pythonic interface
>> to the 0mq core API.
>>
>
> It certainly does and I'm quite fond of pyzmq, I use it in all my existing
> zmq production code.  There's no reason why you shouldn't use one or the
> other, or both at the same time.  pyczmq is going to be slower, guaranteed.
>  CFFI does things in Python interpreter executed code that pyzmq does in
> compiled C code, compiling away the interpreter and there is no doubt in my
> mind that pyzmq is faster.  pyczmq is not an attempt by me to replace pyzmq
> or supersede it in any way, my primary goals were to 1) learn CFFI, 2)
> evaluate the czmq API (it's quite nice, and ironically, "Pythonic" from the
> C point of view, passing the "instance" consistently as the first argument).
>
> Would it make sense for pyzmq to wrap CZMQ as well?
>>
>
> I would say absolutely but I see MinRK doesn't agree.  But, the point is
> kind of moot, as I said you can use both at the same time.  There is no
> difference between czmq sockets and zmq sockets, and you can access the
> inner context object in czmq via zctx_underlying (exposed as
> pyczmq.zctx.underlying).
>

I think making sure the low-level pointers are available in such a way that
you can comfortably pass the zmq sockets and contexts in between the two
libraries would be useful, and should be fairly easy.


>
> -Michel
>
>
>
>>
>>        Greg
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140117/84c5cac4/attachment.htm>


More information about the zeromq-dev mailing list