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 | |
---|
55 | Aside from library development, work on Boost.Python in May was |
---|
56 | focused on reducing the support burden. In recent weeks, responding to |
---|
57 | requests for support, espcially surrounding building the library, had |
---|
58 | begun to impede progress on development. There was a major push to |
---|
59 | release a stable 1.28.0 of Boost, including documentation of <a |
---|
60 | href="../../../../tools/build/v1/build_system.htm">Boost.Build</a> and specific |
---|
61 | <a href="../building.html">instructions</a> for building Boost.Python |
---|
62 | v1. The documentation for Boost.Python v2 was also updated as |
---|
63 | described <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 "creatively designed" |
---|
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 | |
---|
88 | Support for exposing C++ operators and functions as the corresponding |
---|
89 | Python special methods was added. Thinking that the Boost.Python |
---|
90 | v1 interface was a little too esoteric (especially the use of |
---|
91 | <code>left_operand<...>/right_operand<...></code> for |
---|
92 | asymmetric operands), I introduced a simple form of <a |
---|
93 | href="http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html">expression |
---|
94 | templates</a> which allow users to simply write the expressions that |
---|
95 | should be wrapped, as in this <a href="operators.html#examples">example</a>. |
---|
96 | |
---|
97 | <h4><a name="iterators">Iterators</a></h4> |
---|
98 | |
---|
99 | Python iterator support as required by the Kull project resulted in a |
---|
100 | highly 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("__iter__", iterator<list_int>()) |
---|
110 | </pre> |
---|
111 | <dd> |
---|
112 | |
---|
113 | <dt>Creation of iterators from member functions... |
---|
114 | <pre> |
---|
115 | ... |
---|
116 | .def("__iter__" |
---|
117 | , range(&my_class::x_begin, &my_class::x_end)) |
---|
118 | ) |
---|
119 | </pre> |
---|
120 | <dd> |
---|
121 | |
---|
122 | <dt>...and member data: |
---|
123 | <pre> |
---|
124 | ... |
---|
125 | .def("__iter__" |
---|
126 | , range(&std::pair<char*,char*>::first, &std::pair<char*,char*>::second)) |
---|
127 | ) |
---|
128 | </pre> |
---|
129 | <dd> |
---|
130 | |
---|
131 | <dt>The ability to specify <a |
---|
132 | href="CallPolicies.html">CallPolicies</a>, e.g. to prevent copying of |
---|
133 | heavyweight values: |
---|
134 | |
---|
135 | <pre> |
---|
136 | ... |
---|
137 | .def("__iter__", |
---|
138 | , range<return_value_policy<copy_non_const_reference> >( |
---|
139 | &my_sequence<heavy>::begin |
---|
140 | , &my_sequence<heavy>::end)) |
---|
141 | </pre> |
---|
142 | <dd> |
---|
143 | |
---|
144 | </dl> |
---|
145 | |
---|
146 | <h4><a name="properties">Properties</a></h4> |
---|
147 | |
---|
148 | The Kull iteration interfaces also required the ability to iterate |
---|
149 | over a sequence specified by an instance's attribute: |
---|
150 | <pre> |
---|
151 | >>> f = field() |
---|
152 | >>> for e in f.elements: |
---|
153 | ... print e, |
---|
154 | </pre> |
---|
155 | |
---|
156 | This 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_<></code> acquired a <code>setattr</code> member |
---|
167 | function which allows users to easily add new Python objects as class |
---|
168 | attributes. |
---|
169 | |
---|
170 | <h4><a name="module">__module__ Attribute</a></h4> |
---|
171 | |
---|
172 | Ralf Grosse-Kunstleve has been working on pickling support for v2. To |
---|
173 | make 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 | |
---|
178 | The new <code>back_reference<T></code> template can be used as a |
---|
179 | function parameter when the user needs access to both a <code>T</code> |
---|
180 | argument and to the Python object which manages it. The function will |
---|
181 | only match in the overload resolution process if it would match the |
---|
182 | same function signature with <code>T</code> substituted for |
---|
183 | <code>back_reference<T></code>. This feature is not yet |
---|
184 | documented. |
---|
185 | |
---|
186 | <h2><a name="documentation">Documentation</a></h2> |
---|
187 | |
---|
188 | In a major effort to prepare Boost.Python v2 to replace v1, many pages |
---|
189 | of 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> |
---|
212 | Major 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 | |
---|
241 | It appears that the world of C++ <==> Python conversion rules is |
---|
242 | an endlessly-rich area of exploration. Completing the conversions for |
---|
243 | <code>char</code> and <code>char const*</code> types, as described at |
---|
244 | the end of <a href="Apr2002.html#missing">April's report</a>, |
---|
245 | uncovered some interesting new shades to the problem. It turns out to |
---|
246 | be worth distinguishing mutable and immutable lvalue conversions, |
---|
247 | because despite the fact that Python doesn't understand |
---|
248 | <code>const</code>, it does understand immutability (c.f. Python |
---|
249 | strings, which expose an immutable <code>char</code> pointer). It is |
---|
250 | also worth recognizing types which represent lvalue <i>sequences</i>, |
---|
251 | to prevent Python <code>"foobar"</code> from being silently |
---|
252 | truncated to C++ <code>'f'</code>. More details on this insight can be |
---|
253 | found in the mailing list <a |
---|
254 | href="http://mail.python.org/pipermail/c++-sig/2002-May/001023.html"> |
---|
255 | archive</a>. I don't plan to do anything about this immediately, but I |
---|
256 | do think it's the right direction to go in the long run. |
---|
257 | |
---|
258 | <h3><a name="checkins">Checkins Mailing List</a></h3> |
---|
259 | |
---|
260 | In order to better coordinate changes made by multiple developers, I |
---|
261 | enabled <a |
---|
262 | href="http://sourceforge.net/docman/display_doc.php?docid=772&group_id=1">syncmail</a> |
---|
263 | for the Boost.Python CVS trees, and established an associated <a |
---|
264 | href="http://lists.sourceforge.net/lists/listinfo/boost-python-cvs">mailing |
---|
265 | list</a>. Subscribe to this list to receive notices of each new |
---|
266 | checkin. |
---|
267 | |
---|
268 | <h3><a name="shared">Shared Libraries</a></h3> |
---|
269 | |
---|
270 | Beyond the vagaries of dynamic linking on AIX, I have been |
---|
271 | participating in a more-general discussion of dynamic linking for |
---|
272 | C++. Needless to say, C++ dynamic linking is of critical importance to |
---|
273 | Boost.Python: all extension modules are normally built as shared |
---|
274 | libraries, and Boost.Python extension modules share a common library |
---|
275 | as well. |
---|
276 | |
---|
277 | In fact, there are at least two separate conversations. One |
---|
278 | in the C++ standard extensions mailing list concerns what can be |
---|
279 | standardized for C++ and shared libraries; the other, mostly on the <a |
---|
280 | href="http://gcc.gnu.org/ml/gcc/">gcc</a> mailing list, concerns the |
---|
281 | behavior of GCC on Posix/ELF platforms. |
---|
282 | |
---|
283 | Some of the GCC threads are here: |
---|
284 | |
---|
285 | <blockquote> |
---|
286 | <a |
---|
287 | href="http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html">http://gcc.gnu.org/ml/gcc/2002-05/msg02002.html</a><br> |
---|
288 | <a |
---|
289 | href="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 | |
---|
295 | Development is focused on what's needed to be able to retire |
---|
296 | Boost.Python v1. At the moment, that means deciding the user-friendly |
---|
297 | interfaces for to_/from_python conversion, and formally exposing the |
---|
298 | Python object smart pointers and object wrapper classes. Quite a few |
---|
299 | questions have also been showing up recently about how to embed Python |
---|
300 | with Boost.Python, and how to link with it statically; the solutions |
---|
301 | to 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>© Copyright <a href="../../../../people/dave_abrahams.htm">Dave Abrahams</a> |
---|
309 | 2002. </i></p> |
---|
310 | </body> |
---|
311 | </html> |
---|