<H3>SIG for development of Python/C++ integration</H3>
The Python C++ SIG is a forum for discussions about the integration of Python and C++, with an emphasis on the development of the <a href="http://www.boost.org/libs/python/doc/index.html">Boost.Python library</a>. At the point of this writing (Jan 2002), Boost.Python is undergoing a major rewrite to add powerful new features and to take full advantage of the new type system introduced in Python 2.2. Suggestions regarding the direction of the development work and contributions in the form of source code should be posted to this SIG.
<h3>About <a href="http://www.boost.org/libs/python/doc/index.html" >Boost.Python</a></h3>
Boost.Python is a popular open-source tool for interfacing Python and C++. Boost.Python is built on accessible, well-maintained, well documented components (the Boost C++ Library), so it does not tie its users to the services of any one programmer or organization. Developers worldwide have contributed significant unsolicited improvements to the project. The main developer and coordinator of the library is <a href="http://www.boost.org/people/dave_abrahams.htm">David Abrahams</a>.<H3>Development goals</H3>
The following sections describe the current development goals. Suggestions regarding the direction of the development work and contributions in the form of source code should be posted to the Python C++ SIG.
<dt><b>Reference/Pointer support</b> <dd>
Boost.Python currently refuses to wrap C++ functions which return pointers or non-const references, in order to prevent dangling pointers and references from causing crashes on the Python side. This limits the library's ability to export arbitrary C++ functions.
- Goal: Implementation of a mechanism by which references and pointers to internal elements of function and method arguments can be returned safely. This will include a mechanism by which any argument object can be kept alive during the lifetime of any other argument object, so that Wrapped C++ objects can adopt one another without the direct use of smart pointers.
<p> <dt><b>Globally Registered Type Coercions</b> <dd>
Goal: Provide a mechanism for global registration of type relationships between arbitrary Python and C++ types, so that, for example, a Python tuple might be automatically converted to a C++ std::vector when passed to a wrapped function accepting a std::vector argument.
<p> <dt><b>Full Cross-Module Support</b> <dd>
Inheritance hierarchies which span Python extension modules are not currently supported by Boost.Python. Other inter-module interaction issues, e.g. exception handling, are expected to arise.
- Goal: Full support for the interaction of wrapped types and functions residing in different extension modules.
<p> <dt><b>Improved Overloading Support</b> <dd>
Boost.Python's support for overloaded functions and operators is based on throwing C++ exceptions when a signature fails to match the appropriate function. This has several disadvantages: firstly, on many implementations the C++ exception-handling mechanism is highly optimized for the case where no exception is thrown, and throwing an exception can pose serious performance penalties. Secondly, enough C++ implementations have bugs in their exception-handling mechanisms that it is best not to rely on exceptions for routine control flow.
- Goal: Modification of the type conversion mechanism so that overloading can be implemented without the use of C++ exceptions.
<p> <dt><b>C++ to Python Exception Translation</b> <dd>
It is critical for any mature C++ software package to be able to report error conditions via arbitrary exception types. Boost.Python currently provides support for translating only a limited selection of exception types to Python.
- Goal: Implementation of a feature which allows arbitrary new exception types to be registered and automatically translated.
<p> <dt><b>Default Argument Support</b> <dd>
C++ functions with default argument values can currently be exposed to Python, but the defaults are lost.
- Goal: Implementation of compile-time constant default argument expressions. Potentially implementation of lambda expressions for describing default arguments.
<p> <dt><b>Keyword Argument Support</b> <dd>
Python supports the specification of particular function arguments by name, rather than by position.
- Goal: Implementation of a feature which allows keyword arguments to be used from Python for wrapped C++ functions.
<p> <dt><b>Generic C++ to Python Object Interface</b> <dd>
It is often necessary for C++ functions to manipulate objects passed to them directly from Python, without converting them to some other representation. Currently Boost.Python has undocumented support for that usage when the expected Python type is known.
- Goal: Addition of a C++ type which wraps any Python object and provides a similar interface to Python's, with the validity of any operation checked at runtime.
<p> <dt><b>Interface for the application of standard C++ algorithms to Python objects</b> <dd>
Goal: Implementation of interfaces for the application of C++ Standard Template Library algorithms and boost algorithms to Python objects, such as Python lists, tuples, strings and Python objects that support the buffer interface.
<p> <dt><b>Python LONG support</b> <dd>
Python provides an arbitrary-precision LONG integer type which is not currently supported by Boost.Python.
- Goal: Addition of an interface to Python LONGs which allows them to be directly manipulated in C++ with a natural interface.
<p> <dt><b>Improved Built-In Numeric Type Coercion</b> <dd>
Goal: Python supplies at least 4 numeric types, any of which should be able to be passed where an argument of any C++ numeric type is expected, provided that the conversion does not lose significant information.
<p> <dt><b>Python Iterator Support</b> <dd>
Goal: Python 2.2 provides an iteration interface which should allow C++ sequences to be easily exposed to Python in a natural way.
<p> <dt><b>Automatic C++ Object Initialization</b> <dd>
While Python allows classes to be created without initialization, C++ does not. Boost.Python currently allows C++ base classes of Python extension classes to remain uninitialized. That behavior is not always appropriate.
- Goal: Optional support for the automatic default construction of C++ base classes and error reporting when base classes are not initialized.
<p> <dt><b>DocString Support</b> <dd>
Modules, Types, and Functions in Python can be documented with "docstrings", which allow the automatic extraction of documentation (and even testing code) at runtime.
Goal: Full support for docstrings on the elements of C++ extension modules and classes.
<p> <dt><b>C++ long long support</b> <dd>
The long long type is a popular extension to C++ which allows the representation of integer numeric values of at least 64 bits.
- Goal: Automatic conversions of C++ long long values to/from Python.
<p> <dt><b>Code Footprint Reduction</b> <dd>
Currently Boost.Python is not optimized to reduce the code size of the C++ extension modules.
- Goal: Reengineering of Boost.Python so that the code footprint for each extension module is as small as feasible.
<p> <dt><b>Data Memory Footprint Reduction</b> <dd>
Wrapped C++ classes that are not subclassed in Python use more dynamic allocation than necessary, increasing the overall data footprint of an application using Boost.Python extension classes.
- Goal: Embedding of C++ classes directly in Python objects. This will eliminate the overhead due to dynamic allocation.