GET /api/v2/video/2749
HTTP 200 OK Vary: Accept Content-Type: text/html; charset=utf-8 Allow: GET, PUT, PATCH, HEAD, OPTIONS
{ "category": "SciPy 2014", "language": "English", "slug": "integrating-python-and-c-with-boost-python-part-0", "speakers": [ "Austin Bingham" ], "tags": [ "boost", "c++" ], "id": 2749, "state": 1, "title": "Integrating Python and C++ with Boost Python part 1", "summary": "Python and C++ can be powerful complements to one another. C++ is great for performance-critical calculations, while Python is great for everything else. In this tutorial we\u2019ll look at how to integrate Python and C++ using the Boost.Python library. You\u2019ll learn techniques for easily developing hybrid systems that use the right language for the right task, resulting in better software.\r\n", "description": "Python and C++ are both popular languages that each bring a lot to the table. The languages also complement one another well: Python is high-level, dynamic, and easy to use while C++ is at-the-metal, static, and (in)famously tricky. There are times when there are real advantages to combining these disparate natures, and Python\u2019s C API provides a strong interface for doing just that. Boost.Python is a C++ library that builds upon and improves Python\u2019s C API to give users a simpler, more intuitive, and safer means to integrate Python and C++.\r\n\r\nIn this tutorial we\u2019ll look at how to use Boost.Python to effectively bridge the Python/C++ boundary. We\u2019ll start by briefly looking at the fundamentals of the Python C API since that defines the \u201cground rules\u201d; this includes things like reference counting, the basic object model, and so forth. We\u2019ll then quickly look at the Boost.Python API and show how it provides the same functionality as the underlying C API, but does so in a way that doesn\u2019t obscure the real semantics of the Python language.\r\n\r\nAfter this introduction, the rest of the tutorial will involve writing code to explore various elements of Boost.Python. We\u2019ll focus on techniques for extending Python with C++, that is, writing Python modules in C++. Boost.Python can be used for embedding (i.e. invoking Python code from C++), but that involves a different set of techniques, and in practice most scientific Python developers are more interested in developing extensions.\r\n\r\nThe syllabus for the four-hour tutorial will be like this:\r\n\r\n1. Introduction: C-API and Boost.Python basics\r\n\r\n Note that this can be reduced or eliminated of participants are already comfortable with the topics.\r\n\r\n2. Hello World: Exposing a basic function\r\n\r\n In this section we\u2019ll get a minimal Boost.Python module working. This will not only introduce students to the infrastructure of Boost.Python, but it will also give us a chance to make sure that everyone\u2019s build environment is working.\r\n\r\n3. Exposing functions\r\n\r\n In this section we\u2019ll look at the details of exposing C++ functions to Python. The topics we\u2019ll cover will include overloading (including Boost.Python\u2019s auto-overload feature), default argument values, and a brief look at call policies.\r\n\r\n4. Exposing classes\r\n\r\n Here we\u2019ll look at how to expose C++ classes to Python. Topics will include the basic `class_<T>` template, member functions, data members, properties, inheritance, and virtual functions.\r\n\r\n5. `boost::python::object`\r\n\r\n The `boost::python::object` class is Boost.Python\u2019s primary interface to Python\u2019s `PyObject` structure. Understanding how to work with this class is a key building-block for developing Python modules with Boost.Python. We\u2019ll explore its API and features, including areas like attribute access, reference counting, and converting between Python and C++ objects.\r\n\r\n6. Derived object types\r\n\r\n Boost.Python provides a number of `boost::python::object` subclasses for important Python classes like `list`, `dict`, and `tuple`. In this section we\u2019ll look at these subclasses and how to use them in Boost.Python modules.\r\n\r\n7. Enums\r\n\r\n Boost.Python provides `enum_<T>` for exposing C++ enums to Python. Python doesn\u2019t have a notion of enums *per se*, but in this section we\u2019ll explore how this template makes it straightforward to use C++ enums in Python in a simple and intuitive way.\r\n\r\n8. Type conversion\r\n\r\n In this section we\u2019ll look at Boost.Python\u2019s support for doing automatic type-conversion across the Python/C++ boundary. We\u2019ll see how you can register type-converters with Boost.Python which will be invoked whenever Boost.Python needs to convert a Python object to a C++ object or vice versa.\r\n\r\nThis is a fairly ambitious set of topics, and it\u2019s possible that we won\u2019t be able to cover them all. The topics are roughly in most-often-used to least-often-used order, however, so students will be sure to be exposed to the most important and relevant elements of the course.\r\n\r\nLikewise, the four-hour format of the course means that we won\u2019t be able to go into great depth on many topics. The main goal of the course, then, is to give students enough orientation and hands-on experience with Boost.Python that they can continue to learn on their own. Inter-language integration - especially between languages as dissimilar as C++ and Python - can be quite complex, but this tutorial will give students the grounding they need to successfully apply Boost.Python to their problems. \r\n", "quality_notes": "", "copyright_text": "", "embed": "<object width=\"640\" height=\"390\"><param name=\"movie\" value=\";hl=en_US\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\";hl=en_US\" type=\"application/x-shockwave-flash\" width=\"640\" height=\"390\" allowscriptaccess=\"always\" allowfullscreen=\"true\"></embed></object>", "thumbnail_url": "", "duration": null, "video_ogv_length": null, "video_ogv_url": null, "video_ogv_download_only": false, "video_mp4_length": null, "video_mp4_url": null, "video_mp4_download_only": false, "video_webm_length": null, "video_webm_url": null, "video_webm_download_only": false, "video_flv_length": null, "video_flv_url": null, "video_flv_download_only": false, "source_url": "", "whiteboard": "", "recorded": "2014-07-09", "added": "2014-07-10T22:35:18.992", "updated": "2014-07-10T22:35:18.992" }