Skip to content

Commit 8de3571

Browse files
committed
initial checkin
[SVN r13368]
1 parent 5a6bc44 commit 8de3571

1 file changed

Lines changed: 367 additions & 0 deletions

File tree

doc/v2/feb2002.html

Lines changed: 367 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,367 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<meta http-equiv="Content-Type" content=
3+
"text/html; charset=iso-8859-1">
4+
<link rel="stylesheet" type="text/css" href="../boost.css">
5+
6+
<title>Boost.Python - February 2002 Progress Report</title>
7+
<style type="text/css">
8+
:link { color: #0000ff }
9+
:visited { color: #800080 }
10+
p.c3 {font-style: italic}
11+
h2.c2 {text-align: center}
12+
h1.c1 {text-align: center}
13+
</style>
14+
15+
<table border="0" cellpadding="7" cellspacing="0" width=
16+
"100%" summary="header">
17+
<tr>
18+
<td valign="top" width="300">
19+
<h3><a href="http://www.boost.org"><img height="86"
20+
width="277" alt="C++ Boost" src="../c++boost.gif"
21+
border="0"></a></h3>
22+
23+
<td valign="top">
24+
<h1 class="c1">Boost.Python</h1>
25+
26+
<h2 class="c2">February 2002 Progress Report</h2>
27+
</table>
28+
<hr>
29+
30+
<h2>Contents</h2>
31+
32+
<dl class="index">
33+
<dt><a href="#Python10">Python10 Conference Report</a>
34+
35+
<dt><a href="#progress">Boost.Python v2 Progress</a>
36+
37+
<dd>
38+
<dl class="index">
39+
<dt><a href="#documentation">Documentation</a>
40+
41+
<dt><a href="#conversion">Overhaul of
42+
<code>to_python</code>/<code>from_python</code>
43+
conversion mechanism</a>
44+
45+
<dt><a href="#miscellaneous">Miscellaneous</a>
46+
</dl>
47+
</dl>
48+
49+
<h2><a name="Python10">Python10 Conference Report</a></h2>
50+
I spent the first week of February at the Python10 conference
51+
in Alexandria, VA. I&#39;m including this experience report
52+
for two reasons: firstly, it documents where my time was
53+
used. Secondly, a public presence for Boost.Python and
54+
interaction between the Python and C++ communities is
55+
important to the future of Boost.Python, which in turn is
56+
important to the Kull Project.
57+
58+
<p>Andy Koenig, of all people, was the keynote speaker of
59+
this year&#39;s opening plenary session. He presented his
60+
&quot;impressions of a polyglot outsider&quot;, which
61+
studiously avoided any mention of C++ until the end of his
62+
talk, when he was asked about standardization. I was
63+
surprised to learn that the C++ community at large wanted a
64+
few more years before beginning but when ANSI accepted
65+
HP&#39;s request for a standard, the process was forced to
66+
start: it was a matter of participating or having
67+
standardization proceed without one&#39;s input. Andy managed
68+
to highlight very effectively the balance of strengths in
69+
Python, one of the most important being its support for
70+
extension via libraries. In many ways that makes Python a
71+
good analogue for C++ in the interpreted world
72+
73+
<p>There were several kind mentions of the Boost.Python
74+
library from people who found it indispensable. I was
75+
particularly happy that Karl MacMillan, Michael Droettboom,
76+
and Ichiro Fujinaga from Johns Hopkins is using it to do OCR
77+
on a vast library of music notation, since in a previous life
78+
I was an author of music notation software. These guys are
79+
also drawing on Ullrich Koethe&#39;s VIGRA library for image
80+
manipulation (Ullrich has been a major contributor to
81+
Boost.Python). They also have a system for writing the
82+
Boost.Python wrapper code in C++ comments, which allows them
83+
to keep all of the code in one place. I&#39;ve asked them to
84+
send me some information on that.
85+
86+
<p>The development of Swig has been gaining momentum again
87+
(the basic description at
88+
www.boost.org/libs/python/doc/comparisons.html still
89+
applies). The talk given about it by David Beazly was very
90+
well-attended, and they appear to have quite a few users.
91+
Swig&#39;s strengths (coverage of many langauages) and
92+
weaknesses (incomplete C++ language support) haven&#39;t
93+
changed, although the C++ support seems to have improved
94+
considerably - they now claim to have a complete model of the
95+
C++ type system. It seems to be mostly geared at wrapping
96+
what Walter Landry calls &quot;C-Tran&quot;: C++ code which
97+
traffics in built-in types with little use of abstraction.
98+
I&#39;m not knocking that, either: I&#39;m sure a lot of that
99+
code exists, so it&#39;s a valuable service. One feature Swig
100+
has which I&#39;d like to steal is the ability to unwrap a
101+
single Python argument into multiple C++ arguments, for
102+
example, by converting a Python string into a pointer and
103+
length. When his talk was over, David approached me about a
104+
possible joint workshop on language binding, which sounds
105+
like a fun idea to me.
106+
107+
<p>I spent some considerable time talking with Steven Knight,
108+
the leader of the Scons build tool effort. We had a lot to
109+
share with one another, and I gained a much better
110+
appreciation for many of the Scons design decisions. Scons
111+
seems to be concentrating on being the ultimate build system
112+
substrate, and Steve seemed to think that we were on the
113+
right track with our high-level design. We both hope that the
114+
Boost.Build V2 high-level architecture can eventually be
115+
ported to run on top of Scons.
116+
117+
<p>They also have a highly-refined and successful development
118+
procedure which I&#39;d like to emulate for Boost.Build V2.
119+
Among many other things they do, their source-control system
120+
automatically ensures that when you check in a new test, it
121+
is automatically run on the currently checked-in state of the
122+
code, and is expected to fail -- a relatively obvious good
123+
idea which I&#39;ve never heard before.
124+
125+
<p>Guido Van Rossum&#39;s &quot;State of the Python
126+
Union&quot; address was full of questions for the community
127+
about what should be done next, but the one idea Guido seemed
128+
to stress was that core language stability and continuing
129+
library development would be a good idea (sound familiar?) I
130+
mentioned the Boost model as a counterpoint to the idea of
131+
something like CPAN (the massive Perl library archives), and
132+
it seemed to generate some significant interest. I&#39;ve
133+
offered to work with anyone from the Python community who
134+
wants to set up something like Boost.
135+
136+
<p>There was some discussion of &quot;string
137+
interpolation&quot; (variable substitution in strings), and
138+
Guido mentioned that he had some thoughts about the
139+
strengths/weaknesses of Python&#39;s formatting interface. It
140+
might be useful for those working on formatting for boost to
141+
contact him and find out what he has to say.
142+
143+
<p>Ka-Ping Yee demoed a Mailman discussion thread weaver.
144+
This tool weaves the various messages in a discussion thread
145+
into a single document so you can follow the entire
146+
conversation. Since we&#39;re looking very seriously at
147+
moving Boost to Mailman, this could be a really useful thing
148+
for us to have. If we do this, we&#39;ll move the yahoogroups
149+
discussions into the mailman archive so old discussions can
150+
be easily accessed in the same fashion.
151+
152+
<p>And, just because it&#39;s cool, though perhaps not
153+
relevant: http://homepages.ulb.ac.be/~arigo/psyco/ is a
154+
promising effort to accelerate the execution of Python code
155+
to speeds approaching those of compiled languages. It
156+
reminded me a lot of Todd Veldhuizen&#39;s research into
157+
moving parts of C++ template compilation to runtime, only
158+
coming from the opposite end of things.
159+
160+
<h2><a name="progress">Boost.Python v2 Progress</a></h2>
161+
Here&#39;s what actually got accomplished.
162+
163+
<h3><a name="documentation">Documentation</a></h3>
164+
165+
<p>My first priority upon returning from Python10 was to get
166+
some documentation in place. After wasting an unfortunate
167+
amount of time looking at automatic documentation tools which
168+
don&#39;t quite work, I settled down to use Bill Kempf&#39;s
169+
HTML templates designed to be a boost standard. While they
170+
are working well, it is highly labor-intensive.
171+
172+
<p>I decided to begin with the high-level reference material,
173+
as opposed to tutorial, narrative, or nitty-gritty details of
174+
the framework. It seemed more important to have a precise
175+
description of the way the commonly-used components work than
176+
to have examples in HTML (since we already have some test
177+
modules), and since the low-level details are much
178+
less-frequently needed by users it made sense for me to
179+
simply respond to support requests for the time being.
180+
181+
<p>After completing approximately 60% of the high-level docs
182+
(currently checked in to libs/python/doc/v2), I found myself
183+
ready to start documenting the mechanisms for creating
184+
to-/from-python converters. This caused a dilemma: I had
185+
realized during the previous week that a much simpler,
186+
more-efficient, and easier-to-use implementation was
187+
possible, but I hadn&#39;t planned on implementing it right
188+
away, since what was already in place worked adequately. I
189+
had also received my first query on the C++-sig about how to
190+
write such a converter
191+
192+
<p>Given the labor-intensive nature of documentation writing,
193+
I decided it would be a bad idea to document the conversion
194+
mechanism if I was just going to rewrite it. Often the best
195+
impetus for simplifying a design is the realization that
196+
understandably documenting its current state would be too
197+
difficult, and this was no exception.
198+
199+
<h3><a name="conversion">Overhaul of
200+
<code>to_python</code>/<code>from_python</code> conversion
201+
mechanism</a></h3>
202+
203+
<p>There were two basic realizations involved here:
204+
205+
<ol>
206+
<li><code>to_python</code> conversion could be a one-step
207+
process, once an appropriate conversion function is found.
208+
This allows elimination of the separate indirect
209+
convertibility check
210+
211+
<li>There are basically two categories of from_python
212+
conversions: those which lvalues stored within or held by
213+
the Python object (essentially extractions), like what
214+
happens when an instance of a C++ class exposed with class_
215+
is used as the target of a wrapped member function), and
216+
those in which a new rvalue gets created, as when a Python
217+
Float is converted to a C++
218+
<code>complex&lt;double&gt;</code> or a Python tuple is
219+
converted to a C++ <code>std::vector&lt;&gt;</code>. From
220+
the client side, there are two corresponding categories of
221+
conversion: those which demand an lvalue conversion and
222+
those which can accept an lvalue or an rvalue conversion.
223+
</ol>
224+
The latter realization allowed the following collapse, which
225+
considerably simplified things:
226+
227+
<blockquote>
228+
<table border="1" summary="Conversion protocol">
229+
<tr>
230+
<th>Target Type
231+
232+
<th>Eligible Converters
233+
234+
<tr>
235+
<td><code>T</code>
236+
237+
<td rowspan="5"><code>T</code> rvalue or lvalue
238+
239+
<tr>
240+
<td><code>T const</code>
241+
242+
<tr>
243+
<td><code>T volatile</code>
244+
245+
<tr>
246+
<td><code>T const volatile</code>
247+
248+
<tr>
249+
<td><code>T const&amp;</code>
250+
251+
<tr>
252+
<td><code>T const*</code>
253+
254+
<td rowspan="9"><code>T</code> lvalue
255+
256+
<tr>
257+
<td><code>T volatile*</code>
258+
259+
<tr>
260+
<td><code>T const volatile*</code>
261+
262+
<tr>
263+
<td><code>T&amp;</code>
264+
265+
<tr>
266+
<td><code>T volatile&amp;</code>
267+
268+
<tr>
269+
<td><code>T const volatile&amp;</code>
270+
271+
<tr>
272+
<td><code>T* const&amp;</code>
273+
274+
<tr>
275+
<td><code>T const* const&amp;</code>
276+
277+
<tr>
278+
<td><code>T volatile*const&amp;</code>
279+
280+
<tr>
281+
<td><code>T const volatile*const&amp;</code>
282+
</table>
283+
</blockquote>
284+
This job included the following additional enhancements:
285+
286+
<ul>
287+
<li>Elimination of virtual functions, which cause object
288+
code bloat
289+
290+
<li>Registration of a single converter function for all
291+
lvalue conversions, two for all rvalue conversions
292+
293+
<li>Killed lots of unneeded code
294+
295+
<li>Increased opacity of registry interface
296+
297+
<li>Eliminated all need for decorated runtime type
298+
identifiers
299+
300+
<li>Updated test modules to reflect new interface
301+
302+
<li>Eliminated the need for users to worry about converter
303+
lifetime issues Additional Builtin Conversion Enhancements
304+
305+
<li>Support for complex&lt;float&gt;,
306+
complex&lt;double&gt;, and complex&lt;long double&gt;
307+
conversions
308+
309+
<li>Support for bool conversions
310+
311+
<li>NULL pointers representable by None in Python
312+
313+
<li>Support for conversion of Python classic classes to
314+
numeric types
315+
</ul>
316+
317+
<h3><a name="miscellaneous">Miscellaneous</a></h3>
318+
These don&#39;t fit easily under a large heading:
319+
320+
<ul>
321+
<li>Support CallPolicies for class member functions
322+
323+
<li>from_python_data.hpp: revamped type alignment
324+
metaprogram so that it&#39;s fast enough for KCC
325+
326+
<li>classfwd.hpp header forward-declares class_&lt;T&gt;
327+
328+
<li>indirect_traits.hpp:
329+
330+
<li>added is_pointer_to_reference
331+
332+
<li>fixed bugs
333+
334+
<li>Reduced recompilation dependencies
335+
336+
<li>msvc_typeinfo works around broken MS/Intel typeid()
337+
implementation
338+
339+
<li>Many fixes and improvements to the type_traits library
340+
in order to work around compiler bugs and suppress warnings
341+
342+
<li>Eliminated the need for explicit acquisition of
343+
converter registrations
344+
345+
<li>Expanded constructor support to 6 arguments
346+
347+
<li>Implemented generalized pointer lifetime support
348+
349+
<li>Updated code generation for returning.hpp
350+
351+
<li>Tracked down and fixed cycle GC bugs
352+
353+
<li>Added comprehensive unit tests for destroy_reference,
354+
pointer_type_id, select_from_python, complex&lt;T&gt;,
355+
bool, and classic class instance conversions
356+
</ul>
357+
358+
<p>Revised
359+
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
360+
4 April, 2002
361+
<!--webbot bot="Timestamp" endspan i-checksum="39359" -->
362+
363+
364+
<p class="c3">&copy; Copyright <a href=
365+
"../../../../people/dave_abrahams.htm">Dave Abrahams</a>
366+
2002. All Rights Reserved.
367+

0 commit comments

Comments
 (0)