[zeromq-dev] pyzmq ctypes
benjaminrk at gmail.com
Wed May 25 20:48:47 CEST 2011
This is very cool!
Once you have send/recv, you should be mostly there. In PyPy, there's
not much of a reason for most of the rest of the code to not be pure
Most of the challenging code in pyzmq has to do with non-copying sends
and/or buffer-interface providing objects.
For non-copying sends, refcounting is a lot of the tricky bits, and I
don't know how that would change in PyPy which is very different in
that regard. The main point is that if you do:
s.send(buffer) # or memoryview
both Python and libzmq hold a reference to the buffer, and you have to
ensure that neither will free the memory when it's done if the other
still holds its reference.
Much of the buffer-interface difficulty comes from our decision to
support Python 2.5 and 3.x, which makes dealing with the ever-changing
C-API a pain. With PyPy, you may not have to deal with that at all,
and I don't know anything about how PyPy handles memoryviews/buffers
with respect to ctypes.
The only other non-trivial Cython code is the MonitoredQueue device,
but if you drop support for the in-process Thread version, there's no
reason not to rewrite it in Python if your target is PyPy, which
should be quite straightforward (or rewrite it as a pure-C extension
function and call it with ctypes).
On Wed, May 25, 2011 at 07:56, Pieter Hintjens <ph at imatix.com> wrote:
> On Wed, May 25, 2011 at 4:14 PM, Daniel Holth <dholth at gmail.com> wrote:
>> By popular demand (one person asked) the "Release Early" edition of
>> pyzmq-ctypes is at https://bitbucket.org/dholth/pyzmqctypes
> :-) A vote of 1 is still infinitely better than silence.
>> Unlike the Cython version, this binding works in pypy. A file called _zmq.py
>> contains most of the goodies. It implements most of the low-level ZeroMQ API
>> and a tiny bit of the pyzmq wrapper. A serious contributor might want to
>> incorporate the pyzmq unit tests and hack until they run, or go in a
>> different direction by wraping libzapi.
> It's now called czmq, but it'd be interesting to have feedback on how
> easy/hard it is to wrap. Although the goal isn't to get czmq used by
> language bindings, it's a model for other APIs that would be aimed at
> general binding reuse.
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
More information about the zeromq-dev