Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/doc/v2/May2002.html @ 45

Last change on this file since 45 was 29, checked in by landauf, 17 years ago

updated boost from 1_33_1 to 1_34_1

File size: 11.9 KB
Line 
1<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
2<!-- Software License, Version 1.0. (See accompanying -->
3<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
4<html>
5<head>
6<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7<link rel="stylesheet" type="text/css" href="../boost.css">
8<title>Boost.Python - May 2002 Progress Report</title>
9</head>
10<body link="#0000ff" vlink="#800080">
11<table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
12    "header">
13  <tr> 
14    <td valign="top" width="300"> 
15          <h3><a href="../../../../index.htm"><img height="86" width="277" alt=
16          "C++ Boost" src="../../../../boost.png" border="0"></a></h3>
17    </td>
18    <td valign="top"> 
19      <h1 align="center"><a href="../index.html">Boost.Python</a></h1>
20      <h2 align="center">May 2002 Progress Report</h2>
21    </td>
22  </tr>
23</table>
24<hr>
25<h2>Contents</h2>
26<dl class="index">
27  <dt><a href="#intro">Introduction</a></dt>
28  <dt><a href="#features">New Features</a></dt>
29  <dl>
30    <dt><a href="#aix_shared">Shared Library Support for AIX</a><dd>
31    <dt><a href="#class_enhancements">Class Enhancements</a><dd>
32    <dl>
33      <dt><a href="#operators">Operators</a><dd>
34      <dt><a href="#iterators">Iterators</a><dd>
35      <dt><a href="#properties">Properties</a><dd>
36      <dt><a href="#setattr">setattr</a><dd>
37      <dt><a href="#module">__module__ Attribute</a><dd>
38    </dl>
39    <dt><a href="#back_reference">back_reference</a><dd>
40 </dl>
41
42  <dt><a href="#documentation">Documentation</a></dt>
43   <dt><a href="#misc">Miscellaneous</a></dt>
44  <dl class="index">
45    <dt><a href="#converters">Converters</a></dt>
46    <dt><a href="#checkins">Checkins Mailing List</a></dt>
47    <dt><a href="#shared">Shared Libraries</a></dt>
48  </dl>
49
50  <dt><a href="#next">What's Next</a></dt>
51</dl>
52
53<h2><a name="intro">Introduction</a></h2>
54
55Aside from library development, work on Boost.Python in May was
56focused on reducing the support burden. In recent weeks, responding to
57requests for support, espcially surrounding building the library, had
58begun to impede progress on development. There was a major push to
59release a stable 1.28.0 of Boost, including documentation of <a
60href="../../../../tools/build/v1/build_system.htm">Boost.Build</a> and specific
61<a href="../building.html">instructions</a> for building Boost.Python
62v1. The documentation for Boost.Python v2 was also updated as
63described <a href="#documentation">here</a>.
64
65<h2><a name="features">New Features</a></h2>
66
67  <h3><a name="aix_shared">Shared Library Support for AIX</a></h3>
68
69  The Kull group required the ability to build and test Boost.Python
70  extensions on AIX, a platform with &quot;creatively designed&quot;
71  shared library semantics. Making this work was a multi-pronged
72  effort, involving changes to Boost.Build and some great research by
73  Martin Casado which uncovered the key mechanism required to allow
74  shared libraries to use functions from the Python executable. The
75  current solution used in Boost.Build relies on a <a
76  href="../../../../tools/build/v1/gen_aix_import_file.py">Python
77  Script</a> as part of the build process. This is not a problem for
78  Boost.Python, as Python will be available. However, the commands
79  issued by the script are so simple that a 100%-pure-Boost.Jam
80  solution is surely possible. Linking on AIX is sufficiently
81  interesting to have skewed the Boost.Python development schedule a
82  bit.
83
84  <h3><a name="class_enhancements">Class Enhancements</a></h3>
85
86      <h4><a name="operators">Operators</a></h4>
87
88Support for exposing C++ operators and functions as the corresponding
89Python special methods was added. Thinking that the Boost.Python
90v1 interface was a little too esoteric (especially the use of
91<code>left_operand&lt;...&gt;/right_operand&lt;...&gt;</code> for
92asymmetric operands), I introduced a simple form of <a
93href="http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html">expression
94templates</a> which allow users to simply write the expressions that
95should be wrapped, as in this <a href="operators.html#examples">example</a>.
96
97      <h4><a name="iterators">Iterators</a></h4>
98
99Python iterator support as required by the Kull project resulted in a
100highly flexible interface allowing:
101
102<dl>
103
104<dt>Direct exposure of a class' <code>begin()</code> and
105<code>end()</code> functions:
106
107<pre>
108    ...
109    .def(&quot;__iter__&quot;, iterator&lt;list_int&gt;())
110</pre>
111<dd>
112
113<dt>Creation of iterators from member functions...
114<pre>
115    ...
116    .def(&quot;__iter__&quot;
117         , range(&amp;my_class::x_begin, &amp;my_class::x_end))
118    )
119</pre>
120<dd>
121
122<dt>...and member data:
123<pre>
124    ...
125    .def(&quot;__iter__&quot;
126         , range(&amp;std::pair&lt;char*,char*&gt;::first, &amp;std::pair&lt;char*,char*&gt;::second))
127    )
128</pre>
129<dd>
130
131<dt>The ability to specify <a
132href="CallPolicies.html">CallPolicies</a>, e.g. to prevent copying of
133heavyweight values:
134
135<pre>
136    ...
137    .def(&quot;__iter__&quot;,
138         , range&lt;return_value_policy&lt;copy_non_const_reference&gt; &gt;(
139               &amp;my_sequence&lt;heavy&gt;::begin
140             , &amp;my_sequence&lt;heavy&gt;::end))
141</pre>
142<dd>
143
144</dl>
145
146      <h4><a name="properties">Properties</a></h4>
147
148The Kull iteration interfaces also required the ability to iterate
149over a sequence specified by an instance's attribute:
150<pre>
151&gt;&gt;&gt; f = field()
152&gt;&gt;&gt; for e in f.elements:
153...     print e,
154</pre>
155
156This forced the exposure of the <a
157      href="http://www.python.org/2.2/descrintro.html#property"><code>property</code></a>
158      interface used internally to implement the data member exposure
159      facility described in <a
160      href="Mar2002.html#data_members">March</a>. Properties are an
161      incredibly useful idiom, so it's good to be able to provide them
162      at little new development cost.
163
164      <h4><a name="setattr">setattr</a></h4>
165
166<code>class_&lt;&gt;</code> acquired a <code>setattr</code> member
167function which allows users to easily add new Python objects as class
168attributes.
169
170      <h4><a name="module">__module__ Attribute</a></h4>
171
172Ralf Grosse-Kunstleve has been working on pickling support for v2. To
173make it work correctly, he had to make sure that a class'
174<code>__module__</code> attribute was set correctly.
175
176<h3><a name="back_reference"><code>back_reference</code></a></h3>
177
178The new <code>back_reference&lt;T&gt;</code> template can be used as a
179function parameter when the user needs access to both a <code>T</code>
180argument and to the Python object which manages it. The function will
181only match in the overload resolution process if it would match the
182same function signature with <code>T</code> substituted for
183<code>back_reference&lt;T&gt;</code>. This feature is not yet
184documented.
185
186<h2><a name="documentation">Documentation</a></h2>
187
188In a major effort to prepare Boost.Python v2 to replace v1, many pages
189of new reference documentation were added:
190
191<blockquote>
192
193<dl>
194        <dt><a href="CallPolicies.html">CallPolicies.html</a><dd>
195        <dt><a href="Dereferenceable.html">Dereferenceable.html</a><dd>
196        <dt><a href="Extractor.html">Extractor.html</a><dd>
197        <dt><a href="HolderGenerator.html">HolderGenerator.html</a><dd>
198        <dt><a href="ResultConverter.html">ResultConverter.html</a><dd>
199        <dt><a href="call_method.html">call_method.html</a><dd>
200        <dt><a href="callbacks.html">callbacks.html</a><dd>
201        <dt><a href="data_members.html">data_members.html</a><dd>
202        <dt><a href="has_back_reference.html">has_back_reference.html</a><dd>
203        <dt><a href="implicit.html">implicit.html</a><dd>
204        <dt><a href="instance_holder.html">instance_holder.html</a><dd>
205        <dt><a href="operators.html">operators.html</a><dd>
206        <dt><a href="ptr.html">ptr.html</a><dd>
207        <dt><a href="type_id.html">type_id.html</a><dd>
208        <dt><a href="with_custodian_and_ward.html">with_custodian_and_ward.html</a><dd>
209</dl>
210
211</blockquote>
212Major updates were made to the following pages:
213
214
215<blockquote>
216<dl>
217        <dt><a href="call.html">call.html</a><dd> <dt>updated<dd>
218        <dt><a href="class.html">class.html</a><dd>
219        <dt><a href="reference.html">reference.html</a><dd>
220</dl>
221</blockquote>
222
223         As usual, careful documentation forces one to consider the
224         interface again, and there were many interface changes
225         associated with this effort, including the elevation of the
226         following components from implementation detail to
227         first-class library citizen:
228
229<blockquote>
230<dl>
231        <dt>type_id.hpp<dd>
232        <dt>pointee.hpp<dd>
233        <dt>lvalue_from_pytype.hpp<dd></dl>
234</dl>
235</blockquote>
236
237<h2><a name="misc">Miscellaneous</a></h2>
238
239    <h3><a name="converters">Converters</a></h3>
240
241It appears that the world of C++ &lt;==&gt; Python conversion rules is
242an endlessly-rich area of exploration. Completing the conversions for
243<code>char</code> and <code>char const*</code> types, as described at
244the end of <a href="Apr2002.html#missing">April's report</a>,
245uncovered some interesting new shades to the problem. It turns out to
246be worth distinguishing mutable and immutable lvalue conversions,
247because despite the fact that Python doesn't understand
248<code>const</code>, it does understand immutability (c.f. Python
249strings, which expose an immutable <code>char</code> pointer). It is
250also worth recognizing types which represent lvalue <i>sequences</i>,
251to prevent Python <code>&quot;foobar&quot;</code> from being silently
252truncated to C++ <code>'f'</code>. More details on this insight can be
253found in the mailing list <a
254href="http://mail.python.org/pipermail/c++-sig/2002-May/001023.html">
255archive</a>. I don't plan to do anything about this immediately, but I
256do think it's the right direction to go in the long run.
257
258    <h3><a name="checkins">Checkins Mailing List</a></h3>
259
260In order to better coordinate changes made by multiple developers, I
261enabled <a
262href="http://sourceforge.net/docman/display_doc.php?docid=772&group_id=1">syncmail</a>
263for the Boost.Python CVS trees, and established an associated <a
264href="http://lists.sourceforge.net/lists/listinfo/boost-python-cvs">mailing
265list</a>. Subscribe to this list to receive notices of each new
266checkin.
267
268    <h3><a name="shared">Shared Libraries</a></h3>
269
270Beyond the vagaries of dynamic linking on AIX, I have been
271participating in a more-general discussion of dynamic linking for
272C++. Needless to say, C++ dynamic linking is of critical importance to
273Boost.Python: all extension modules are normally built as shared
274libraries, and Boost.Python extension modules share a common library
275as well.
276
277In fact, there are at least two separate conversations. One
278in the C++ standard extensions mailing list concerns what can be
279standardized for C++ and shared libraries; the other, mostly on the <a
280href="http://gcc.gnu.org/ml/gcc/">gcc</a> mailing list, concerns the
281behavior of GCC on Posix/ELF platforms.
282
283Some of the GCC threads are here:
284
285<blockquote>
286<a
287href="http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html">http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html</a><br>
288<a
289href="http://gcc.gnu.org/ml/gcc/2002-05/msg02945.html">http://gcc.gnu.org/ml/gcc/2002-05/msg02945.html</a><br>
290<a href="http://gcc.gnu.org/ml/gcc/2002-05/msg01758.html">http://gcc.gnu.org/ml/gcc/2002-05/msg01758.html</a>
291</blockquote>
292
293  <h2><a name="next">What's Next</a></h2>
294
295Development is focused on what's needed to be able to retire
296Boost.Python v1. At the moment, that means deciding the user-friendly
297interfaces for to_/from_python conversion, and formally exposing the
298Python object smart pointers and object wrapper classes. Quite a few
299questions have also been showing up recently about how to embed Python
300with Boost.Python, and how to link with it statically; the solutions
301to these issues will probably have to be formalized before long.
302
303<p>Revised
304  <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
305  13 November, 2002
306  <!--webbot bot="Timestamp" endspan i-checksum="39359" -->
307</p>
308<p><i>&copy; Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a> 
309  2002. </i></p>
310</body>
311</html>
Note: See TracBrowser for help on using the repository browser.