Providing a C ++ Library for Python + PIL

I started using SWIG in a huge C ++ library (from several interdependent static libraries) to expose it in python. This library defines many primitive classes that are used as parameters (for example, images of different types). STL, inheritance, and templates are also widely used in lib.

So far I have the minimum part of lib used from Python, but I would like to gradually add the remaining 90 +%.

For its part, working with SWIG is actually not interesting: fighting templates, learning the whole SWIG syntax and keywords, etc. I recently worked a little with CTypes and found it so enjoyable that I am now considering writing extern C for the entire library instead of using SWIG.

I would rather code in C / C ++ and / or Python than to study the obscure set of SWIG commands (this also applies to SIP).

There are many questions that similar advice is already asking, so I will add something new and specific:

I would like the classes of the internal library images to be visible with Python as PIL images transparently, and not as SWIG-Wrapped native classes. Should I resort to a simple external Python API to accomplish this?

Welcome any advice!

+3
source share
1 answer

Have you considered using Boost.Python?

+1
source

Source: https://habr.com/ru/post/1795603/


All Articles