mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
https://svn.boost.org/svn/boost/trunk ........ r41077 | troyer | 2007-11-13 23:00:02 -0800 (Tue, 13 Nov 2007) | 1 line Added support for std::complex to serialization ........ r41078 | joaquin | 2007-11-13 23:09:29 -0800 (Tue, 13 Nov 2007) | 1 line added missing include ........ r41079 | djowel | 2007-11-14 02:13:51 -0800 (Wed, 14 Nov 2007) | 1 line adjust to compensate for lack of <small> tag. ........ r41080 | djowel | 2007-11-14 02:17:09 -0800 (Wed, 14 Nov 2007) | 1 line refresh docs ........ r41081 | djowel | 2007-11-14 02:23:23 -0800 (Wed, 14 Nov 2007) | 1 line refresh docs ........ r41082 | djowel | 2007-11-14 02:24:21 -0800 (Wed, 14 Nov 2007) | 1 line refresh docs ........ r41083 | anthonyw | 2007-11-14 03:08:09 -0800 (Wed, 14 Nov 2007) | 1 line ignore and join all threads in group on exception ........ r41084 | anthonyw | 2007-11-14 03:56:53 -0800 (Wed, 14 Nov 2007) | 1 line interrupt and join all threads in a group if an exception is thrown during a test ........ r41086 | johnmaddock | 2007-11-14 04:14:19 -0800 (Wed, 14 Nov 2007) | 1 line Merged changes from the Sandbox to Trunk. ........ r41087 | anthonyw | 2007-11-14 04:17:41 -0800 (Wed, 14 Nov 2007) | 1 line interrupt and join all threads in a group if an exception is thrown during a test ........ r41088 | johnmaddock | 2007-11-14 04:41:32 -0800 (Wed, 14 Nov 2007) | 1 line Added WinCE workaround. ........ r41089 | johnmaddock | 2007-11-14 05:03:15 -0800 (Wed, 14 Nov 2007) | 1 line Catch exceptions thrown from thread creation. ........ r41090 | anthonyw | 2007-11-14 06:49:58 -0800 (Wed, 14 Nov 2007) | 1 line fixes for pthread implementation ........ r41091 | bemandawes | 2007-11-14 07:50:43 -0800 (Wed, 14 Nov 2007) | 1 line Replace old docs with excerpts from http://article.gmane.org/gmane.comp.lib.boost.testing/5020 ........ r41093 | eric_niebler | 2007-11-14 08:36:15 -0800 (Wed, 14 Nov 2007) | 1 line fix support for segmented iteration ........ r41094 | dave | 2007-11-14 09:37:55 -0800 (Wed, 14 Nov 2007) | 3 lines Update command-prompt instructions per http://news.gmane.org/find-root.php?message_id=%3cfhcrem%24c4%241%40ger.gmane.org%3e ........ r41095 | bemandawes | 2007-11-14 12:05:30 -0800 (Wed, 14 Nov 2007) | 1 line Bring docs more in line with reality:-) ........ r41097 | hljin | 2007-11-14 18:07:53 -0800 (Wed, 14 Nov 2007) | 1 line GIL: removed the example directory from the documentation as it is a duplication and re-directed the Doxygen documentation to a local copy (to be submitted next) ........ r41098 | hljin | 2007-11-14 18:30:13 -0800 (Wed, 14 Nov 2007) | 1 line GIL: added a local copy of the Doxygen documentation ........ r41099 | hljin | 2007-11-14 18:32:04 -0800 (Wed, 14 Nov 2007) | 1 line GIL: added a local copy of the Doxygen documentation (second batch) ........ r41100 | chris_kohlhoff | 2007-11-14 22:19:04 -0800 (Wed, 14 Nov 2007) | 6 lines Try to fix an order-of-initialisation problem with error_category references. The symptom, which only occurs in some applications, is a crash due to a dereference of a null pointer. The exact conditions under which the problem occurs are not fully understood, so this fix is probably more paranoid than necessary. ........ r41102 | jhunold | 2007-11-14 23:04:24 -0800 (Wed, 14 Nov 2007) | 1 line Suppress msvc "deprecated" warnings. ........ r41103 | johnmaddock | 2007-11-15 01:52:26 -0800 (Thu, 15 Nov 2007) | 1 line Fix some compiler warnings when building with the Intel and aCC compilers. ........ r41104 | garcia | 2007-11-15 04:50:48 -0800 (Thu, 15 Nov 2007) | 2 lines John Torjo is reviewing the X-files. ........ r41105 | hkaiser | 2007-11-15 05:27:24 -0800 (Thu, 15 Nov 2007) | 1 line Suppressed more warnings during build of Wave. ........ r41106 | bemandawes | 2007-11-15 06:36:40 -0800 (Thu, 15 Nov 2007) | 1 line GetUserDefaultUILanguage isn't present for Cygwin, so disable use ........ r41107 | bemandawes | 2007-11-15 07:20:27 -0800 (Thu, 15 Nov 2007) | 1 line Get rid of .cvsignore files ........ r41108 | eric_niebler | 2007-11-15 08:06:22 -0800 (Thu, 15 Nov 2007) | 1 line fix typo ........ r41110 | grafik | 2007-11-15 08:58:21 -0800 (Thu, 15 Nov 2007) | 1 line Fix building of multiple regression tools at once. ........ r41111 | gmelquio | 2007-11-15 09:52:31 -0800 (Thu, 15 Nov 2007) | 1 line Fixed documentation typo. ........ r41113 | grafik | 2007-11-15 10:56:43 -0800 (Thu, 15 Nov 2007) | 1 line Switch intel-win32 to use static multi thread runtime since the single thread static runtime is no longer available. (fixes #1287) ........ r41114 | andreas_huber69 | 2007-11-15 11:22:12 -0800 (Thu, 15 Nov 2007) | 1 line Added new FAQ item suggested by Chris Paulse. ........ r41116 | guwi17 | 2007-11-15 12:52:37 -0800 (Thu, 15 Nov 2007) | 4 lines This patch now lets the Sun compiler work for most of uBLAS. 'test4' is now failing. Too avoid other compilers complaining about missing return values in some functions where exceptions are thrown, code was added so an arbitatry were chosen. ........ r41117 | danmarsden | 2007-11-15 13:15:47 -0800 (Thu, 15 Nov 2007) | 1 line removing failing test on EDG compilers ........ r41118 | grafik | 2007-11-15 14:05:15 -0800 (Thu, 15 Nov 2007) | 1 line Remove redundant reference to system library. It causes double linking when used indirectly through filesystem. Which can lead to double linking incompatible variants when a specific filesystem variant is requested. ........ r41119 | grafik | 2007-11-15 14:05:22 -0800 (Thu, 15 Nov 2007) | 1 line Oops, forgot we need to use the root boost project settings when building. ........ [SVN r41141]
155 lines
9.0 KiB
HTML
155 lines
9.0 KiB
HTML
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
<title>Chapter 1. python 1.0</title>
|
||
<link rel="stylesheet" href="../../../../../../doc/html/boostbook.css" type="text/css">
|
||
<meta name="generator" content="DocBook XSL Stylesheets V1.66.1">
|
||
<link rel="start" href="index.html" title="Chapter 1. python 1.0">
|
||
<link rel="next" href="python/hello.html" title=" Building Hello World">
|
||
</head>
|
||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
<table cellpadding="2" width="100%"><tr>
|
||
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
|
||
<td align="center"><a href="../../../../../../index.htm">Home</a></td>
|
||
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
|
||
<td align="center"><a href="../../../../../../people/people.htm">People</a></td>
|
||
<td align="center"><a href="../../../../../../more/faq.htm">FAQ</a></td>
|
||
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/html/images/next.png" alt="Next"></a></div>
|
||
<div class="chapter" lang="en">
|
||
<div class="titlepage"><div>
|
||
<div><h2 class="title">
|
||
<a name="python"></a>Chapter 1. python 1.0</h2></div>
|
||
<div><div class="author"><h3 class="author">
|
||
<span class="firstname">Joel</span> <span class="surname">de Guzman</span>
|
||
</h3></div></div>
|
||
<div><div class="author"><h3 class="author">
|
||
<span class="firstname">David</span> <span class="surname">Abrahams</span>
|
||
</h3></div></div>
|
||
<div><p class="copyright">Copyright © 2002-2005 Joel
|
||
de Guzman, David Abrahams</p></div>
|
||
<div><div class="legalnotice">
|
||
<a name="id455917"></a><p>
|
||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">
|
||
http://www.boost.org/LICENSE_1_0.txt </a>)
|
||
</p>
|
||
</div></div>
|
||
</div></div>
|
||
<div class="toc">
|
||
<p><b>Table of Contents</b></p>
|
||
<dl>
|
||
<dt><span class="section"><a href="index.html#python.quickstart">QuickStart</a></span></dt>
|
||
<dt><span class="section"><a href="python/hello.html"> Building Hello World</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html"> Exposing Classes</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="python/exposing.html#python.constructors">Constructors</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.class_data_members">Class Data Members</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.class_properties">Class Properties</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.inheritance">Inheritance</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.class_virtual_functions">Class Virtual Functions</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.virtual_functions_with_default_implementations">Virtual Functions with Default Implementations</a></span></dt>
|
||
<dt><span class="section"><a href="python/exposing.html#python.class_operators_special_functions">Class Operators/Special Functions</a></span></dt>
|
||
</dl></dd>
|
||
<dt><span class="section"><a href="python/functions.html">Functions</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="python/functions.html#python.call_policies">Call Policies</a></span></dt>
|
||
<dt><span class="section"><a href="python/functions.html#python.overloading">Overloading</a></span></dt>
|
||
<dt><span class="section"><a href="python/functions.html#python.default_arguments">Default Arguments</a></span></dt>
|
||
<dt><span class="section"><a href="python/functions.html#python.auto_overloading">Auto-Overloading</a></span></dt>
|
||
</dl></dd>
|
||
<dt><span class="section"><a href="python/object.html"> Object Interface</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="python/object.html#python.basic_interface">Basic Interface</a></span></dt>
|
||
<dt><span class="section"><a href="python/object.html#python.derived_object_types">Derived Object types</a></span></dt>
|
||
<dt><span class="section"><a href="python/object.html#python.extracting_c___objects">Extracting C++ objects</a></span></dt>
|
||
<dt><span class="section"><a href="python/object.html#python.enums">Enums</a></span></dt>
|
||
</dl></dd>
|
||
<dt><span class="section"><a href="python/embedding.html">Embedding</a></span></dt>
|
||
<dd><dl><dt><span class="section"><a href="python/embedding.html#python.using_the_interpreter">Using the interpreter</a></span></dt></dl></dd>
|
||
<dt><span class="section"><a href="python/iterators.html">Iterators</a></span></dt>
|
||
<dt><span class="section"><a href="python/exception.html"> Exception Translation</a></span></dt>
|
||
<dt><span class="section"><a href="python/techniques.html"> General Techniques</a></span></dt>
|
||
<dd><dl>
|
||
<dt><span class="section"><a href="python/techniques.html#python.creating_packages">Creating Packages</a></span></dt>
|
||
<dt><span class="section"><a href="python/techniques.html#python.extending_wrapped_objects_in_python">Extending Wrapped Objects in Python</a></span></dt>
|
||
<dt><span class="section"><a href="python/techniques.html#python.reducing_compiling_time">Reducing Compiling Time</a></span></dt>
|
||
</dl></dd>
|
||
</dl>
|
||
</div>
|
||
<div class="section" lang="en">
|
||
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
|
||
<a name="python.quickstart"></a>QuickStart</h2></div></div></div>
|
||
<p>
|
||
The Boost Python Library is a framework for interfacing Python and C++. It
|
||
allows you to quickly and seamlessly expose C++ classes functions and objects
|
||
to Python, and vice-versa, using no special tools -- just your C++ compiler.
|
||
It is designed to wrap C++ interfaces non-intrusively, so that you should not
|
||
have to change the C++ code at all in order to wrap it, making Boost.Python
|
||
ideal for exposing 3rd-party libraries to Python. The library's use of advanced
|
||
metaprogramming techniques simplifies its syntax for users, so that wrapping
|
||
code takes on the look of a kind of declarative interface definition language
|
||
(IDL).
|
||
</p>
|
||
<a name="quickstart.hello_world"></a><h2>
|
||
<a name="id385257"></a>
|
||
Hello World
|
||
</h2>
|
||
<p>
|
||
Following C/C++ tradition, let's start with the "hello, world". A
|
||
C++ Function:
|
||
</p>
|
||
<pre class="programlisting">
|
||
<span class="keyword">char</span> <span class="keyword">const</span><span class="special">*</span> <span class="identifier">greet</span><span class="special">()</span>
|
||
<span class="special">{</span>
|
||
<span class="keyword">return</span> <span class="string">"hello, world"</span><span class="special">;</span>
|
||
<span class="special">}</span>
|
||
</pre>
|
||
<p>
|
||
can be exposed to Python by writing a Boost.Python wrapper:
|
||
</p>
|
||
<pre class="programlisting">
|
||
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">python</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
|
||
|
||
<span class="identifier">BOOST_PYTHON_MODULE</span><span class="special">(</span><span class="identifier">hello_ext</span><span class="special">)</span>
|
||
<span class="special">{</span>
|
||
<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">python</span><span class="special">;</span>
|
||
<span class="identifier">def</span><span class="special">(</span><span class="string">"greet"</span><span class="special">,</span> <span class="identifier">greet</span><span class="special">);</span>
|
||
<span class="special">}</span>
|
||
</pre>
|
||
<p>
|
||
That's it. We're done. We can now build this as a shared library. The resulting
|
||
DLL is now visible to Python. Here's a sample Python session:
|
||
</p>
|
||
<p>
|
||
</p>
|
||
<pre class="programlisting">
|
||
<span class="special">>>></span> <span class="keyword">import</span> <span class="identifier">hello_ext</span>
|
||
<span class="special">>>></span> <span class="keyword">print</span> <span class="identifier">hello</span><span class="special">.</span><span class="identifier">greet</span><span class="special">()</span>
|
||
<span class="identifier">hello</span><span class="special">,</span> <span class="identifier">world</span>
|
||
</pre>
|
||
<p>
|
||
</p>
|
||
<div class="blockquote"><blockquote class="blockquote">
|
||
<p>
|
||
</p>
|
||
<p>
|
||
<span class="emphasis"><em><span class="bold"><b>Next stop... Building your Hello World
|
||
module from start to finish...</b></span></em></span>
|
||
</p>
|
||
<p>
|
||
</p>
|
||
</blockquote></div>
|
||
</div>
|
||
</div>
|
||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||
<td align="left"><p><small>Last revised: November 07, 2007 at 03:34:24 GMT</small></p></td>
|
||
<td align="right"><div class="copyright-footer"></div></td>
|
||
</tr></table>
|
||
<hr>
|
||
<div class="spirit-nav"><a accesskey="n" href="python/hello.html"><img src="../../../../../../doc/html/images/next.png" alt="Next"></a></div>
|
||
</body>
|
||
</html>
|