diff --git a/doc/cross_module_dependencies.html b/doc/cross_module_dependencies.html index cd0cc02d..08c39bfe 100644 --- a/doc/cross_module_dependencies.html +++ b/doc/cross_module_dependencies.html @@ -82,6 +82,8 @@ to a Python object and vice versa (i.e. the to_python() and example:
+ #include <boost/python/cross_module.hpp> + //... class_builder<std::vector<double> > v_double(std_vector_module, "double"); export_converters(v_double);@@ -91,6 +93,8 @@ these converters with the import_converters<> template. For example:
+ #include <boost/python/cross_module.hpp>
+ //...
import_converters<std::vector<double> > v_double_converters("std_vector", "double");
@@ -248,28 +252,64 @@ the Boost.Python extension module with the
import_converters<> statement need to be linked against
the object library. Ideally one would build a shared library (e.g.
libdvect.so, dvect.dll, etc.). However, this
-introduces the issue of getting the search path for the dynamic loading
-configured correctly. For small libraries it is therefore often more
-convenient to ignore the fact that the object files are loaded into
-memory more than once.
+introduces the issue of having to configure the search path for the
+dynamic loading correctly. For small libraries it is therefore often
+more convenient to ignore the fact that the object files are loaded
+into memory more than once.
+
+-The main purpose of Boost.Python's support for resolving cross-module -dependencies at runtime is to allow for a modular system layout. With -this support it is straightforward to reflect C++ code organization at -the Python level. Without the cross-module support, a multi-purpose -module like std_vector would be impractical because the entire -wrapper code would somehow have to be duplicated in all extension -modules that use it, making them harder to maintain and harder to -build. +Another motivation for the cross-module support is that two extension +modules that wrap the same class cannot both be imported into Python. +For example, if there are two modules A and B that +both wrap a given class X, this will work: + +
+import A +x = A.X() ++ +This will also work: + +
+import B +x = B.X() ++ +However, this will fail: + +
+import A +import B +python: /net/cci/rwgk/boost/boost/python/detail/extension_class.hpp:866: +static void boost::python::detail::class_registry<X>::register_class(boost::python::detail::extension_class_base *): +Assertion `static_class_object == 0' failed. +Abort ++ +A good solution is to wrap class X only once. Depending on the +situation, this could be done by module A or B, or an +additional small extension module that only wraps and exports +class X.
-Finally, there is an important psychological component. If a group of -classes is lumped together with many others in a huge module, the -authors will have difficulties in being identified with their work. -The situation is much more transparent if the work is represented by -a module with a recognizable name. This is not just a question of -strong egos, but also of getting credit and funding. +Finally, there can be important psychological or political reasons for +using the cross-module support. If a group of classes is lumped +together with many others in a huge module, the authors will have +difficulties in being identified with their work. The situation is +much more transparent if the work is represented by a module with a +recognizable name. This is not just a question of strong egos, but also +of getting credit and funding.
-Updated: March 2001 +Updated: April 2001