What's your first choice if you have to write a C module for python?

James Matthews nytrokiss at gmail.com
Tue Aug 26 20:55:14 CEST 2008


ctypes and swig for me

On Tue, Aug 26, 2008 at 9:04 AM, Ulrich Eckhardt <eckhardt at satorlaser.com>wrote:

> 一首诗 wrote:
> > I read this interesting post comparing Boost.Python with Pyd:
> >
> > http://pyd.dsource.org/vsboost.html
> >
> > What's your opinion about it?
> >
> > What's your first choice when you have write a C/C++ module for Python?
>
> There is no such thing as a C/C++ language. Seriously, both are really
> different and require different approaches. That said, when writing a C++
> module I use Boost.Python, for one because Boost is already part of many
> C++ projects but also because it is simply very easy and convenient to use.
>
> There is another alternative, ctypes, which also works but it IMHO brings
> many of the disadvantages of C to Python. In particular those are manual
> resource management and lack of exceptions. Looking at Boost.Python though,
> you can simply throw a C++ exception and it gets mapped to a Python
> exception, and resource management is also a non issue since you can make
> ownership transfers explicit.
>
> Now, concerning pyd, I think you are comparing apples to oranges. If you
> had
> asked which language I would chose to write a Python plugin, that would
> have been a totally different thing. To that, the answer is in order of
> preference:
>  1. Python ;)
>  2. C++ with Boost.Python
>  3. C with ctypes
>
> cheers
>
> Uli
>
>
> --
> Sator Laser GmbH
> Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
http://www.goldwatches.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080826/08f330ce/attachment.html>


More information about the Python-list mailing list