Extending Python Without Python’s C API
You can code Python extensions in other classic compiled languages besides C. For Fortran, the choice is between Paul Dubois’s Pyfort (available at http://pyfortran.sf.net) and Pearu Peterson’s F2PY (available at http://cens.ioc.ee/projects/f2py2e/). Both packages support and require the Numeric package covered in The Numeric Package, since numeric processing is Fortran’s typical application area.
For C++, you have many choices. SCXX (available at http://davidf.sjsoft.com/mirrors/mcmillan-inc/scxx.html) is a simple, lightweight package that uses no templates and is thus suitable for older C++ compilers. PyCXX (available at http://cxx.sf.net) uses a modest amount of templates, essentially ones from the C++ standard library. SIP (available at http://www.riverbankcomputing.co.uk/sip/index.php) also supports the C++ extensions needed to use the powerful Qt cross-platform libraries, but, while it fully supports Qt, it does not require it. The Boost Python Library (available at http://www.boost.org/libs/python/doc) is part of Boost, a vast treasury of powerful, template-rich C++ libraries, of uniformly high quality, that need and support modern C++ compilers that support templates very well.
Of course, you may also choose to use Python’s C API from your C++ code, using C++ in this respect as if it were C, and foregoing the extra convenience that C++ affords. However, if you’re already using C++ rather than C anyway, then using SCXX, PyCXX, SIP, or ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access