diff --git a/doc/v2/ObjectWrapper.html b/doc/v2/ObjectWrapper.html new file mode 100644 index 00000000..c7d555cd --- /dev/null +++ b/doc/v2/ObjectWrapper.html @@ -0,0 +1,155 @@ + + + +
+ + + + +|
+ |
+
+
+ Boost.Python+ +ObjectWrapper and TypeWrapper Concepts+ |
+
This page defines two concepts used to describe classes which manage a + Python objects, and which are intended to support usage with a + Python-like syntax.
+ +R is itself an TypeWrapper, a member function invocation of
+ the form
++x.some_function(a1, a2,...an) ++ always has semantics equivalent to: +
+extract<R>(x.attr("some_function")(object(a1), object(a2),...object(an)))()
+
+ When the R is an TypeWrapper, the result type may be
+ constructed by taking direct posession of:
+
+x.attr("some_function")(object(a1), object(a2),...object(an)).ptr()
+
+ [see caveat below]
+
+ X. For a given TypeWrapper
+ T, a valid constructor expression
++T(a1, a2,...an) ++ builds a new
T object managing the result of invoking
+ X with arguments corresponding to
++object(a1), object(a2),...object(an) ++ +When used as arguments to wrapped C++ functions, or as the template +parameter to
extract<>, only
+instances of the associated Python type will be considered a match.
+
+ dict member function items
+ returns an object of type list. Now suppose the user defines this
+ dict subclass in Python:
++>>> class mydict(dict): +... def items(self): +... return tuple(dict.items(self)) # return a tuple ++ Since an instance of
mydict is also an instance of
+ dict, when used as an argument to a wrapped C++ function,
+ boost::python::dict can
+ accept objects of Python type mydict. Invoking
+ items() on this object can result in an instance of boost::python::list which actually
+ holds a Python tuple. Subsequent attempts to use list methods (e.g.
+ append, or any other mutating operation) on this object will
+ raise the same exception that would occur if you tried to do it from
+ Python.
+ Revised + + 30 Sept, 2002 +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ +Permission to copy, use, modify, sell and distribute this software is + granted provided this copyright notice appears in all copies. This + software is provided "as is" without express or implied warranty, and + with no claim as to its suitability for any purpose.
+ + + diff --git a/doc/v2/args.html b/doc/v2/args.html new file mode 100644 index 00000000..93443091 --- /dev/null +++ b/doc/v2/args.html @@ -0,0 +1,103 @@ + + + + + + + + +|
+ |
+
+
+ Boost.Python+ +Header <boost/python/args.hpp>+ |
+
args(...)Supplies a family of overloaded functions for specifying argument + keywords for wrapped C++ functions.
+ +A keyword-expression results in an object which holds a + sequence of ntbses, and whose type + encodes the number of keywords specified.
+ +args(...)+unspecified1 args(char const*); +unspecified2 args(char const*, char const*); + . + . + . +unspecifiedN args(char const*, char const*, ... char const*); ++ +
+#include <boost/python/def.hpp>
+using namespace boost::python;
+
+int f(int x, int y, int z);
+
+BOOST_PYTHON_MODULE_INIT(xxx)
+{
+ def("f", f, args("x", "y", "z"));
+}
+
+
+ Revised 05 November, 2001
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+ + + diff --git a/doc/v2/class.html b/doc/v2/class.html index 240a1364..c66bf8dc 100644 --- a/doc/v2/class.html +++ b/doc/v2/class.html @@ -247,7 +247,7 @@ namespace boost { namespace python { template <class T - , class Bases = bases<> + , class Bases = bases<> , class HeldType = T , class NonCopyable = unspecified > @@ -742,23 +742,26 @@ template <class Policies> properties, used to describe a family of__init__ methods to
be generated for an extension class:
- __doc__ attribute++
+- docstring: An ntbs + whose value will bound to the method's
-__doc__+ attribute- keywords: A keyword-expression which will be - used to name (a trailing subset of) the arguments to the generated -
+__init__function(s).- keywords: A keyword-expression which will be + used to name (a trailing subsequence of) the arguments to the generated +
-__init__function(s).- call policies: An instance of a model of CallPolicies.
+- call policies: An instance of a model of CallPolicies.
-- argument types: An MPL sequence of C++ argument types which - will be used to construct the wrapped C++ object. An init expression - has one or more valid prefixes which are given by a sequence of - prefixes of its argument types.
-- argument types: An MPL sequence of C++ argument types + which will be used to construct the wrapped C++ object. An init + expression has one or more valid prefixes which are given by a + sequence of prefixes of its argument types.
+
optional<T1
= unspecified, T2 =
diff --git a/doc/v2/faq.html b/doc/v2/faq.html
index 78a3940f..8e8be4e5 100644
--- a/doc/v2/faq.html
+++ b/doc/v2/faq.html
@@ -1,39 +1,75 @@
+
+
-
-
-
-|
- |
-
- Boost.Python-Frequently Asked Questions (FAQs)- |
-
{{answer}}
-{{answer}}
-Revised - - 05 November, 2002 - -
-© Copyright Dave Abrahams - 2002. All Rights Reserved.
- +
+ Q: I have an object composed of 12 doubles. A const& to this object is + returned by a member function of another class. From the viewpoint of + using the returned object in Python I do not care if I get a copy or a + reference to the returned object. In Boost.Python Version 2 I have the + choice of using copy_const_reference or return_internal_reference. Are + there considerations that would lead me to prefer one over the other, + such as size of generated code or memory overhead? + ++ +A: copy_const_reference will make an instance with storage for one of + your objects, size = base_size + 12 * sizeof(double). + return_internal_reference will make an instance with storage for a + pointer to one of your objects, size = base_size + sizeof(void*). + However, it will also create a weak reference object which goes in the + source object's weakreflist and a special callback object to manage the + lifetime of the internally-referenced object. My guess? + copy_const_reference is your friend here, resulting in less overall + memory use and less fragmentation, also probably fewer total cycles.
+
{{answer}}
+Revised + + 05 November, 2002 + +
+ +© Copyright Dave Abrahams 2002. All Rights + Reserved.
+