What's your first choice if you have to write a C module for python?
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
> 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
> 1. Python ;)
> 2. C++ with Boost.Python
> 3. C with ctypes
> Sator Laser GmbH
> Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list