3

I started using SWIG on a huge C++ library (made of of several inter-dependent static libs) to expose it to python. This library defines many primitive classes that are used throughout as parameters (images of different types for example). There is extensive use of STL, inheritance and templating in the lib as well.

So far I have a minimal portion of the lib usable from Python but would like to progressively add the remaining 90+%.

For my part, working with SWIG is really no fun: Battling with template instantiations, learning all that SWIG syntax and keywords, etc. I recently played a bit with CTypes and found it so enjoyable that I am now considering writing an extern C interface for the whole library instead of using SWIG.

I would rather be coding in C/C++ and/or Python than learning an obscure set of SWIG commands (that counts for SIP also).

There are quite a few questions out there already asking similar advice so I'll add something new and specific:

I would like for the library's internal images classes to be visible from python as PIL images transparently, not as SWIG-Wrapped native classes. Will I have to resort to the plain-old Python External API to accomplish that?

I welcome any and all advice!

Zot Ditz Myo
  • 93
  • 1
  • 6
  • I can't beleive I missed out on this thread: http://stackoverflow.com/questions/1076300/extending-python-with-c-c Still more options! – Zot Ditz Myo Mar 02 '11 at 14:07
  • I did not have the time yet to look into the issue but should do so in the next month. I will probably try a few methods and post my findings/opinions here. – Zot Ditz Myo Apr 05 '11 at 08:47

1 Answers1

1

Have you considered looking into using Boost.Python?

Ken Smith
  • 775
  • 5
  • 11
  • Sure I have come across it while doing my search but I have never used boost before. Is it safe to install along-side the standard C++ libraries without collisions? (I use Visual Studio 2005 and still have nightmares of the time I was using MSVC6.0 and Roguewave ++shudder++). I will have to REALLY look into it then. Thanks for the eye opener! – Zot Ditz Myo Mar 02 '11 at 01:49
  • I have used Boost alongside the standard C++ libraries with GCC with no issues whatever. I have heard of folks doing the same with Visual Studio. Boost is very mature and contains many high quality libraries and I have trusted it enough to use in production software. I have used Boost.Python and Luabind (like Boost.Python but for Lua) and have been impressed with how easy they are to work with. – Ken Smith Mar 02 '11 at 17:28