You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Alan Conway <ac...@redhat.com> on 2014/05/23 14:06:44 UTC
dispatch: using SWIG
What's the general feeling about using SWIG in dispatch? To date
dispatch uses hand-crafted calls based on Python.h primitives. My
impression is that works OK for a small python/C interface but the
interface is getting to the point where SWIG may be helpful.
Opinions anyone? Objections?
Cheers,
Alan.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org
Re: dispatch: using SWIG
Posted by Alan Conway <ac...@redhat.com>.
On Thu, 2014-05-29 at 12:37 -0400, Alan Conway wrote:
> My concern is that as the boundary of interaction grows it will become
> complicated and error-prone to maintain hand-written wrappers. E.g. look
> at router_pynode.c. It's a lot of hand-written call-Python-from-C code
> to generate a python class view of a C API. I suspect that a thin swig
> wrapper between clean Python code and a clean C API would be easier to
> understand and maintain thank this C/Python mish-mash. (I might be
> wrong, if I am I won't do it :)
cffi looks quite promising: it's basically C-in-python rather than
python-in-C which is the right way around IMO. It lets us skip the SWIG
wrapper and go straight from python to C in a fairly clean way. Hmm...
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org
Re: dispatch: using SWIG
Posted by Alan Conway <ac...@redhat.com>.
On Thu, 2014-05-29 at 08:31 -0400, Rafael Schloming wrote:
> If you're strictly concerned about C <-> Python interop and not concerned
> with providing bindings in other languages, there are a number of other
> tools that could help (cffi, ctypes, and Cython). This page lists them and
> talks about some of their pros and cons:
> https://packaging.python.org/en/latest/extensions.html
>
Thanks! How about tools that go the other way: C calling python? Doing
things by hand with the basic Python.h primitives is pretty verbose and
error prone: are there any tools that will generate safer/easier to use
C APIs for specific python classes?
> On Wed, May 28, 2014 at 9:09 AM, Darryl L. Pierce <dp...@redhat.com>
> wrote:
>
> > On Fri, May 23, 2014 at 08:06:44AM -0400, Alan Conway wrote:
> > > What's the general feeling about using SWIG in dispatch? To date
> > > dispatch uses hand-crafted calls based on Python.h primitives. My
> > > impression is that works OK for a small python/C interface but the
> > > interface is getting to the point where SWIG may be helpful.
> > >
> > > Opinions anyone? Objections?
> >
> > Hrm, I'm not sure it would be the right way to go. Swig is great for
> > taking a library and present it as a dynamic module for languages like
> > Python, Perl and Ruby. But for what Dispatch is doing, we're already
> > using the Python development code that provides C <-> Python interfaces;
> > i.e., we're already doing what Swig would be asked to do for us in the
> > codebase. Unless we're going to have Dispatch be a totally Python
> > application that depends on a library of functions written in C,
> > shouldn't we keep things the way they are now and leverage that level of
> > control?
My concern is that as the boundary of interaction grows it will become
complicated and error-prone to maintain hand-written wrappers. E.g. look
at router_pynode.c. It's a lot of hand-written call-Python-from-C code
to generate a python class view of a C API. I suspect that a thin swig
wrapper between clean Python code and a clean C API would be easier to
understand and maintain thank this C/Python mish-mash. (I might be
wrong, if I am I won't do it :)
I'm not rushing to change things yet, just getting the lie of the land.
Cheers,
Alan.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org
Re: dispatch: using SWIG
Posted by Rafael Schloming <rh...@alum.mit.edu>.
If you're strictly concerned about C <-> Python interop and not concerned
with providing bindings in other languages, there are a number of other
tools that could help (cffi, ctypes, and Cython). This page lists them and
talks about some of their pros and cons:
https://packaging.python.org/en/latest/extensions.html
--Rafael
On Wed, May 28, 2014 at 9:09 AM, Darryl L. Pierce <dp...@redhat.com>
wrote:
> On Fri, May 23, 2014 at 08:06:44AM -0400, Alan Conway wrote:
> > What's the general feeling about using SWIG in dispatch? To date
> > dispatch uses hand-crafted calls based on Python.h primitives. My
> > impression is that works OK for a small python/C interface but the
> > interface is getting to the point where SWIG may be helpful.
> >
> > Opinions anyone? Objections?
>
> Hrm, I'm not sure it would be the right way to go. Swig is great for
> taking a library and present it as a dynamic module for languages like
> Python, Perl and Ruby. But for what Dispatch is doing, we're already
> using the Python development code that provides C <-> Python interfaces;
> i.e., we're already doing what Swig would be asked to do for us in the
> codebase. Unless we're going to have Dispatch be a totally Python
> application that depends on a library of functions written in C,
> shouldn't we keep things the way they are now and leverage that level of
> control?
>
> --
> Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc.
> Delivering value year after year.
> Red Hat ranks #1 in value among software vendors.
> http://www.redhat.com/promo/vendor/
>
>
Re: dispatch: using SWIG
Posted by "Darryl L. Pierce" <dp...@redhat.com>.
On Fri, May 23, 2014 at 08:06:44AM -0400, Alan Conway wrote:
> What's the general feeling about using SWIG in dispatch? To date
> dispatch uses hand-crafted calls based on Python.h primitives. My
> impression is that works OK for a small python/C interface but the
> interface is getting to the point where SWIG may be helpful.
>
> Opinions anyone? Objections?
Hrm, I'm not sure it would be the right way to go. Swig is great for
taking a library and present it as a dynamic module for languages like
Python, Perl and Ruby. But for what Dispatch is doing, we're already
using the Python development code that provides C <-> Python interfaces;
i.e., we're already doing what Swig would be asked to do for us in the
codebase. Unless we're going to have Dispatch be a totally Python
application that depends on a library of functions written in C,
shouldn't we keep things the way they are now and leverage that level of
control?
--
Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc.
Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/
Re: dispatch: using SWIG
Posted by Ted Ross <tr...@redhat.com>.
I have no objections to using Swig. It's a build-only dependency.
Keep in mind that Swig is only useful for Python -> C calls. If we are
going to widen the native API offered to Python, it might be wise to
introduce Swig.
-Ted
On 05/23/2014 08:06 AM, Alan Conway wrote:
> What's the general feeling about using SWIG in dispatch? To date
> dispatch uses hand-crafted calls based on Python.h primitives. My
> impression is that works OK for a small python/C interface but the
> interface is getting to the point where SWIG may be helpful.
>
> Opinions anyone? Objections?
>
> Cheers,
> Alan.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
> For additional commands, e-mail: dev-help@qpid.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org