2
0
mirror of https://github.com/boostorg/python.git synced 2026-01-24 18:12:43 +00:00

details from the introduction moved to design goals section

[SVN r16864]
This commit is contained in:
Ralf W. Grosse-Kunstleve
2003-01-10 19:22:13 +00:00
parent 84a8fb71b8
commit 72b214b8db

View File

@@ -91,24 +91,11 @@ facilities provided by Python alone for integration with C++ are
relatively meager. Some of this, such as the need to manage
reference-counting manually and lack of C++ exception-handling
support, comes from the limitations of the 'C' language in which the
API is implemented. Those issues aside,most of the hard problems and
much of the tedium of exposing C++ in Python extension modules can be
handled if the code understands the C++ type system. For example:
API is implemented.
* Every argument of every wrapped function requires some kind of
extraction code to convert it from Python to C++. Likewise, the
function return value has to be converted from C++ to Python.
Appropriate Python exceptions must be raised if the conversion
fails. Argument and return types are part of the function's type,
and much of this tedium can be relieved if the wrapping system can
extract that information through introspection.
* Passing a wrapped C++ derived class instance to a C++ function
accepting a pointer or reference to a base class requires knowledge
of the inheritance relationship and how to translate the address of
a base class into that of a derived class.
The Boost.Python Library (BPL) leverages the power of C++
Most of the hard problems and much of the tedium of exposing C++ in
Python extension modules can be handled if the code understands the C++
type system. The Boost.Python Library (BPL) leverages the power of C++
meta-programming techniques to introspect about the C++ type system,
and presents a simple, IDL-like C++ interface for exposing C++ code in
extension modules.
@@ -128,6 +115,17 @@ example, though C++ and Python both have an iterator concept, they are
expressed very differently. Boost.Python has to be able to bridge the
interface gap.
Every argument of every wrapped function must be converted
automatically from Python to C++. Likewise, the function return value
must be converted automatically from C++ to Python. Appropriate
Python exceptions must be raised if the conversion fails.
It must be possible to pass a wrapped C++ derived class instance to a
C++ function accepting a pointer or reference to a base class. For
this Boost.Python has to maintain a graph of the inheritance
relationships including information on how to translate the address of
a base class into that of a derived class.
It must be possible to insulate Python users from crashes resulting
from trivial misuses of C++ interfaces, such as accessing
already-deleted objects. By the same token the library should