+1 -1 +7
Vote on this proposal

Which Python binding library should you use?

by Maninya M (proposing)

Section
Core Python
Technical level
Intermediate

This is a proposal requesting for someone to speak on this topic. If you’d like to speak, leave a comment.

Objective

This talk introduces the audience to the notion of writing high performance code in C/C++ and then exposing it to Python through different techniques.

Audience

Developers interested in integrating Python with C/C++ libraries.

Description

Writing Python bindings for a C/C++ library is about providing the ease of use of a very high-level, compact language to it, while still keeping the benefits of speed of the C library. However, choosing the right binding libraries for your application could affect how you get the benefits of both languages. So which do you choose: Boost::Python? SWIG? SIP? Or just be rigorous and use the Python/C API?

Detailed Abstract

Choosing a Python binding library for your application requires a good knowledge of:
1) How the application or software has been written - what data structures does it use? How are the classes and functions? How does the application scale?
2) What is important for the application - Is it speed/performance? Scalability? Accuracy?
3) What are the Python binding libraries out there, and what do they have to offer?
4) Which one will work best for your application?

Writing extension modules for your C/C++ libraries is a trade-off between using tools to simply generate a thin wrapper without much abstraction - this would work brilliantly for functions that you can write only in one way, and using these tools to produce a more intelligent wrapper, that would use the usual idioms/practices that are prevalent in Python. A more sophisticated wrapper would make useful abstractions between the C API and the Python API, while still maintaining most functionality in the C API.

Outline

  • From C++ to Python using Python C API, Boost::Python, Swig or Sip. (10 min)
  • Why would anyone want to do that (5 min)
  • Basics of Python C API (15 min)
  • Classes and objects binding (5 min)
  • Garbage collection (5 min)
  • Life of a bound object (5 min)
  • To Boost::Python or to Sip (10 min)
  • Questions (5 min)

Duration:: 1 hour

Speaker bio

Satheesh Subramanian heads the Research & Development department at DreamWorks Animation in Bangalore. He leads a dev team that works on various different aspects of movie making - a lighting software, an animation software and asset management/web-service, etc.