<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>tag:old.nabble.com,2006:forum-2927</id>
	<title>Nabble - Python - c++-sig</title>
	<updated>2009-11-30T11:09:48Z</updated>
	<link rel="self" type="application/atom+xml" href="http://old.nabble.com/Python---c++-sig-f2927.xml" />
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Python---c%2B%2B-sig-f2927.html" />
	<subtitle type="html">Development of Python/C++ integration</subtitle>
	
<entry>
	<id>tag:old.nabble.com,2006:post-26581411</id>
	<title>Re: Embedding Python - creating Python objects from C++</title>
	<published>2009-11-30T11:09:48Z</published>
	<updated>2009-11-30T11:09:48Z</updated>
	<author>
		<name>Sohail Somani-2</name>
	</author>
	<content type="html">On 29/11/09 7:50 PM, Sohail Somani wrote:
&lt;br&gt;&amp;gt; // constructs a new instance of UserClass in Python using magic
&lt;br&gt;&amp;gt; // but uses shared_ptr to keep alive
&lt;br&gt;&amp;gt; shared_ptr&amp;lt;Base&amp;gt; base(/* magic here */);
&lt;br&gt;&lt;br&gt;This seemed to work:
&lt;br&gt;&lt;br&gt;// Boost Python/C++
&lt;br&gt;class_&amp;lt;Base,shared_ptr&amp;lt;Base&amp;gt; &amp;gt;(&amp;quot;Base&amp;quot;)
&lt;br&gt;&amp;nbsp; .def(...)
&lt;br&gt;;
&lt;br&gt;&lt;br&gt;# Python
&lt;br&gt;class UserClass(Base):
&lt;br&gt;&amp;nbsp; &amp;nbsp;...
&lt;br&gt;&lt;br&gt;// Back in C++
&lt;br&gt;object = module[&amp;quot;UserClass&amp;quot;]
&lt;br&gt;shared_ptr&amp;lt;Base&amp;gt; ptr = extract&amp;lt;shared_ptr&amp;lt;Base&amp;gt; &amp;gt;(object());
&lt;br&gt;&lt;br&gt;I'll find out soon enough if it works like I'm expecting ;-)
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Sohail Somani
&lt;br&gt;&lt;a href=&quot;http://uint32t.blogspot.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://uint32t.blogspot.com&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26581411&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Embedding-Python---creating-Python-objects-from-C%2B%2B-tp26568235p26581411.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26568235</id>
	<title>Embedding Python - creating Python objects from C++</title>
	<published>2009-11-29T16:50:13Z</published>
	<updated>2009-11-29T16:50:13Z</updated>
	<author>
		<name>Sohail Somani-2</name>
	</author>
	<content type="html">I have a class in C++ as follows:
&lt;br&gt;&lt;br&gt;class Base
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;virtual ~Base() /* ideally like = 0 but doesn't seem to work */;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;I export this class to Python:
&lt;br&gt;&lt;br&gt;class_&amp;lt;Base&amp;gt;(&amp;quot;Base&amp;quot;,no_init);
&lt;br&gt;&lt;br&gt;The user is expected to create a derived class:
&lt;br&gt;&lt;br&gt;class UserClass(Base):
&lt;br&gt;&amp;nbsp; &amp;nbsp;... stuff here ...
&lt;br&gt;&lt;br&gt;&lt;br&gt;What I want to do then (in C++) is create instances of this Python class 
&lt;br&gt;that are stored using a shared pointer:
&lt;br&gt;&lt;br&gt;&amp;nbsp; // constructs a new instance of UserClass in Python using magic
&lt;br&gt;&amp;nbsp; // but uses shared_ptr to keep alive
&lt;br&gt;shared_ptr&amp;lt;Base&amp;gt; base(/* magic here */);
&lt;br&gt;&lt;br&gt;I understand that I can do something like module.attr(&amp;quot;UserClass&amp;quot;)() to 
&lt;br&gt;create an instance but that will return an object instance which doesn't 
&lt;br&gt;seem like it would play nice if I extracted a Base pointer from it.
&lt;br&gt;&lt;br&gt;So does anyone know how to implement the above referenced magic? It 
&lt;br&gt;sounds like it should be obvious, but I'm not sure.
&lt;br&gt;&lt;br&gt;Thanks, and sorry if this is a newb question!
&lt;br&gt;&lt;br&gt;Sohail
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26568235&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Embedding-Python---creating-Python-objects-from-C%2B%2B-tp26568235p26568235.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26522351</id>
	<title>Re: Getting Boost.Python Working on MacOS X</title>
	<published>2009-11-25T15:44:52Z</published>
	<updated>2009-11-25T15:44:52Z</updated>
	<author>
		<name>Randolph Fritz-2</name>
	</author>
	<content type="html">On 2009-11-23, Martin Hediger &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522351&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;ma.hed@...&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have been trying to get Boost.Python working on my MBP with Mac OS
&lt;br&gt;&amp;gt; 10.5, since I need it to compile the chemical modeling software
&lt;br&gt;&amp;gt; &amp;quot;AVOGADRO&amp;quot; for modification reasons.
&lt;br&gt;&lt;br&gt;There's something wrong with the boost.python test script on Mac OS X;
&lt;br&gt;see &amp;lt;&lt;a href=&quot;https://svn.boost.org/trac/boost/ticket/2185&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://svn.boost.org/trac/boost/ticket/2185&lt;/a&gt;&amp;gt;. &amp;nbsp;That's probably
&lt;br&gt;what's making problems for you. &amp;nbsp;Boost.python does in fact work on
&lt;br&gt;Mac, despite the test script problem; here's what I did to make it go:
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://mail.python.org/pipermail/cplusplus-sig/2009-October/014871.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/pipermail/cplusplus-sig/2009-October/014871.html&lt;/a&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Randolph Fritz
&lt;br&gt;&amp;nbsp; design machine group, architecture department, university of washington
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522351&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rfritz@...&lt;/a&gt; -or- &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522351&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;rfritz333@...&lt;/a&gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26522351&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Getting-Boost.Python-Working-on-MacOS-X-tp26477173p26522351.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26519563</id>
	<title>Re: boost python and weak_ptr from a shared_ptr argument</title>
	<published>2009-11-25T12:13:50Z</published>
	<updated>2009-11-25T12:13:50Z</updated>
	<author>
		<name>Ralf W. Grosse-Kunstleve</name>
	</author>
	<content type="html">This is a known problem. Boost.Python builds shared_ptr instances when calling your functions, using a custom deleter. I think internally it just uses regular Python reference counting to manage the lifetime of your KBObject.
&lt;br&gt;&lt;br&gt;Unfortunately I don't have a nice suggestion for you. A few years ago I worked around the issue in this way:
&lt;br&gt;&lt;br&gt;struct KBOject_data {
&lt;br&gt;&amp;nbsp; std::string name;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;&lt;br&gt;struct KBOject {
&lt;br&gt;&amp;nbsp; boost::shared_ptr&amp;lt;KBOject_data&amp;gt; data;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;I.e. by hiding the shared_ptr from Boost.Python.
&lt;br&gt;It isn't pretty. Maybe someone else has a better solution?
&lt;br&gt;(I've always been wondering if enable_shared_from_this could make this nice.)
&lt;br&gt;&lt;br&gt;&lt;br&gt;----- Original Message ----
&lt;br&gt;From: Jahn Fuchs &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26519563&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;jfuchs@...&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26519563&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;Sent: Wed, November 25, 2009 8:16:58 AM
&lt;br&gt;Subject: [C++-sig] boost python and weak_ptr from a shared_ptr argument
&lt;br&gt;&lt;br&gt;Hello boost python users,
&lt;br&gt;&lt;br&gt;I really like boost python but I stumbled in a problem I don't know how to solve, maybe you have an idea:
&lt;br&gt;&lt;br&gt;I have a class KnowledgeBase that holds an shared_ptr to an KBObject and also a weak_ptr to an KBObject. &amp;nbsp;If I set the shared_ptr with the set_shared_ptr function it works fine, but it doesn't work with the set_weak_ptr function (which takes a shared_ptr as an argument) ...
&lt;br&gt;&lt;br&gt;see the following C++ code, python export code and python test code to see what i mean. I made a simple example which I also tested and it shows the problem I have.
&lt;br&gt;&lt;br&gt;Thank you in advance.
&lt;br&gt;jahn.
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26519563&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/boost-python-and-weak_ptr-from-a-shared_ptr-argument-tp26515754p26519563.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26518120</id>
	<title>Re: building modules with MSVC</title>
	<published>2009-11-25T10:41:51Z</published>
	<updated>2009-11-25T10:41:51Z</updated>
	<author>
		<name>Brian O'Kennedy-2</name>
	</author>
	<content type="html">It&amp;#39;s certainly possible. &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;* Create a project in Visual Studio, set the output type to DLL.  &lt;/div&gt;&lt;div&gt;* Go to Linker-&amp;gt;Output and name the DLL as mymodule.pyd (pyd&amp;#39;s are just DLLs on Windows). &lt;/div&gt;

&lt;div&gt;* Set the Additional Library paths to where you keep your boost python stub lib for linking. &lt;/div&gt;* You might need to specify the folder to the python lib too. &lt;br&gt;&lt;div&gt;* Including the boost python headers will automatically cause the stub lib to be linked against. &lt;/div&gt;

&lt;div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;This is from memory so might be missing out a step or two. &lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Hope this helps,&lt;/div&gt;&lt;div&gt; Brian&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/11/25 Simon Pickles &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26518120&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;sipickles@...&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;

&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;Hi,&lt;br&gt;
&lt;br&gt;
Is it possible to build boost::python modules using MSVC as opposed to bjam?&lt;br&gt;
&lt;br&gt;
I&amp;#39;d like MSVC to output a pyd of course.&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;
Simon&lt;br&gt;
_______________________________________________&lt;br&gt;
Cplusplus-sig mailing list&lt;br&gt;
&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26518120&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;&lt;br&gt;
&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;
&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26518120&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/building-modules-with-MSVC-tp26512414p26518120.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26515754</id>
	<title>boost python and weak_ptr from a shared_ptr argument</title>
	<published>2009-11-25T08:16:58Z</published>
	<updated>2009-11-25T08:16:58Z</updated>
	<author>
		<name>Jahn Fuchs</name>
	</author>
	<content type="html">Hello boost python users,
&lt;br&gt;&lt;br&gt;I really like boost python but I stumbled in a problem I don't know how 
&lt;br&gt;to solve, maybe you have an idea:
&lt;br&gt;&lt;br&gt;I have a class KnowledgeBase that holds an shared_ptr to an KBObject and 
&lt;br&gt;also a weak_ptr to an KBObject. &amp;nbsp;If I set the shared_ptr with the 
&lt;br&gt;set_shared_ptr function it works fine, but it doesn't work with the 
&lt;br&gt;set_weak_ptr function (which takes a shared_ptr as an argument) ...
&lt;br&gt;&lt;br&gt;see the following C++ code, python export code and python test code to 
&lt;br&gt;see what i mean. I made a simple example which I also tested and it 
&lt;br&gt;shows the problem I have.
&lt;br&gt;&lt;br&gt;Thank you in advance.
&lt;br&gt;jahn.
&lt;br&gt;&lt;br&gt;&lt;br&gt;// C++ CODE:
&lt;br&gt;-------------------------------------------------------------------------
&lt;br&gt;class KBObject {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::string name;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;class KnowledgeBase {
&lt;br&gt;public:
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boost::shared_ptr&amp;lt;KBObject&amp;gt; obj_shared_ptr;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boost::weak_ptr&amp;lt;KBObject&amp;gt; obj_weak_ptr;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void set_weak_ptr(boost::shared_ptr&amp;lt;KBObject&amp;gt; obj_ptr) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; obj_weak_ptr = boost::weak_ptr&amp;lt;KBObject&amp;gt;(obj_ptr);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void set_shared_ptr(boost::shared_ptr&amp;lt;KBObject&amp;gt; obj_ptr) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; obj_shared_ptr = obj_ptr;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boost::shared_ptr&amp;lt;KBObject&amp;gt; get_shared_ptr() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return obj_shared_ptr;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boost::shared_ptr&amp;lt;KBObject&amp;gt; get_weak_ptr() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return obj_weak_ptr.lock();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void print_weak_ptr() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (boost::shared_ptr&amp;lt;KBObject&amp;gt;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; obj_ptr = obj_weak_ptr.lock())
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; obj_ptr.get()-&amp;gt;name &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; &amp;quot;NO OBJECT&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; void print_shared_ptr() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (obj_shared_ptr.get()!=0)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; obj_shared_ptr.get()-&amp;gt;name
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; std::cout &amp;lt;&amp;lt; &amp;quot;NO OBJECT&amp;quot; &amp;lt;&amp;lt; std::endl;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; };
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;// PYTHON MODULE EXPORT ----------------------------------------------
&lt;br&gt;BOOST_PYTHON_MODULE(kbpython)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;using namespace boost::python;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class_&amp;lt;KBObject, boost::shared_ptr&amp;lt;KBObject&amp;gt; &amp;gt;(&amp;quot;KBObject&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .def_readwrite(&amp;quot;name&amp;quot;, &amp;KBObject::name)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;class_&amp;lt;KnowledgeBase&amp;gt;(&amp;quot;KnowledgeBase&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;set_shared_ptr&amp;quot;, &amp;KnowledgeBase::set_shared_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;set_weak_ptr&amp;quot;, &amp;KnowledgeBase::set_weak_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_shared_ptr&amp;quot;, &amp;KnowledgeBase::get_shared_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_weak_ptr&amp;quot;, &amp;KnowledgeBase::get_weak_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;print_weak_ptr&amp;quot;, &amp;KnowledgeBase::print_weak_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;print_shared_ptr&amp;quot;, &amp;KnowledgeBase::print_shared_ptr)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&lt;br&gt;// PYTHON TEST PROGRAM -----------------------------------------------
&lt;br&gt;&lt;br&gt;#!/usr/bin/env python
&lt;br&gt;import kbpython
&lt;br&gt;&lt;br&gt;kb = kbpython.KnowledgeBase()
&lt;br&gt;&lt;br&gt;obj = kbpython.KBObject()
&lt;br&gt;obj.name = &amp;quot;myObject&amp;quot;
&lt;br&gt;kb.set_shared_ptr(obj)
&lt;br&gt;kb.print_shared_ptr()
&lt;br&gt;&lt;br&gt;obj_2 = kb.get_shared_ptr()
&lt;br&gt;obj_2.name = &amp;quot;change_name&amp;quot;
&lt;br&gt;kb.print_shared_ptr()
&lt;br&gt;&lt;br&gt;kb.set_weak_ptr(obj_2)
&lt;br&gt;kb.print_weak_ptr()
&lt;br&gt;&lt;br&gt;&lt;br&gt;------------------------------------------------------------------------
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26515754&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/boost-python-and-weak_ptr-from-a-shared_ptr-argument-tp26515754p26515754.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26512414</id>
	<title>building modules with MSVC</title>
	<published>2009-11-25T05:11:06Z</published>
	<updated>2009-11-25T05:11:06Z</updated>
	<author>
		<name>Simon Pickles-2</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;Is it possible to build boost::python modules using MSVC as opposed to bjam?
&lt;br&gt;&lt;br&gt;I'd like MSVC to output a pyd of course.
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;Simon
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26512414&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/building-modules-with-MSVC-tp26512414p26512414.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26497646</id>
	<title>Re: multithreading and interpreters</title>
	<published>2009-11-24T07:11:36Z</published>
	<updated>2009-11-24T07:11:36Z</updated>
	<author>
		<name>Matthew Scouten (TT)</name>
	</author>
	<content type="html">I'm sorry, I meant massively *patched* BP
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@...&lt;/a&gt;
&lt;br&gt;[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@py
&lt;br&gt;thon.org] On Behalf Of Matthew Scouten (TT)
&lt;br&gt;Sent: Tuesday, November 24, 2009 8:58 AM
&lt;br&gt;To: Development of Python/C++ integration
&lt;br&gt;Subject: Re: [C++-sig] multithreading and interpreters
&lt;br&gt;&lt;br&gt;Multiple threads is do-able, but you have to manage the GIL manually.
&lt;br&gt;Multiple interpreters is more difficult. I think that it has been done
&lt;br&gt;before by someone who massively BP, but I have never tried it. 
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@...&lt;/a&gt;
&lt;br&gt;[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@py
&lt;br&gt;thon.org] On Behalf Of Trigve Siver
&lt;br&gt;Sent: Sunday, November 22, 2009 10:56 AM
&lt;br&gt;To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;Subject: [C++-sig] multithreading and interpreters
&lt;br&gt;&lt;br&gt;Hi,
&lt;br&gt;I'm working on project where we used boost.python (embedded).
&lt;br&gt;&lt;br&gt;In general I have the &amp;quot;modules&amp;quot; where each module is something like
&lt;br&gt;sandbox, is
&lt;br&gt;isolated from others modules and run in solo thread. I want to be able
&lt;br&gt;to use 
&lt;br&gt;python (and boost python functions of course) from each module thread.
&lt;br&gt;Something
&lt;br&gt;like that each thread could have own interpreter without need to take
&lt;br&gt;care of GIL and
&lt;br&gt;like. Is it possible? I know there could be some problems with GIL and
&lt;br&gt;so. I've found in 
&lt;br&gt;python C API docs Py_NewInterpreter() function which could be of help
&lt;br&gt;(or not?).
&lt;br&gt;&lt;br&gt;So will this configuration work? Could be there some problems with
&lt;br&gt;boost.python
&lt;br&gt;when using multiple threads?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;Trigve
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497646&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/multithreading-and-interpreters-tp26466990p26497646.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26497520</id>
	<title>Re: multithreading and interpreters</title>
	<published>2009-11-24T06:57:37Z</published>
	<updated>2009-11-24T06:57:37Z</updated>
	<author>
		<name>Matthew Scouten (TT)</name>
	</author>
	<content type="html">Multiple threads is do-able, but you have to manage the GIL manually.
&lt;br&gt;Multiple interpreters is more difficult. I think that it has been done
&lt;br&gt;before by someone who massively BP, but I have never tried it. 
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From:
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497520&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@...&lt;/a&gt;
&lt;br&gt;[mailto:cplusplus-sig-bounces+matthew.scouten=tradingtechnologies.com@py
&lt;br&gt;thon.org] On Behalf Of Trigve Siver
&lt;br&gt;Sent: Sunday, November 22, 2009 10:56 AM
&lt;br&gt;To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497520&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;Subject: [C++-sig] multithreading and interpreters
&lt;br&gt;&lt;br&gt;Hi,
&lt;br&gt;I'm working on project where we used boost.python (embedded).
&lt;br&gt;&lt;br&gt;In general I have the &amp;quot;modules&amp;quot; where each module is something like
&lt;br&gt;sandbox, is
&lt;br&gt;isolated from others modules and run in solo thread. I want to be able
&lt;br&gt;to use 
&lt;br&gt;python (and boost python functions of course) from each module thread.
&lt;br&gt;Something
&lt;br&gt;like that each thread could have own interpreter without need to take
&lt;br&gt;care of GIL and
&lt;br&gt;like. Is it possible? I know there could be some problems with GIL and
&lt;br&gt;so. I've found in 
&lt;br&gt;python C API docs Py_NewInterpreter() function which could be of help
&lt;br&gt;(or not?).
&lt;br&gt;&lt;br&gt;So will this configuration work? Could be there some problems with
&lt;br&gt;boost.python
&lt;br&gt;when using multiple threads?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;Trigve
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497520&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26497520&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/multithreading-and-interpreters-tp26466990p26497520.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26477173</id>
	<title>Getting Boost.Python Working on MacOS X</title>
	<published>2009-11-23T04:05:36Z</published>
	<updated>2009-11-23T04:05:36Z</updated>
	<author>
		<name>Martin Hediger</name>
	</author>
	<content type="html">Dear All
&lt;br&gt;&lt;br&gt;I have been trying to get Boost.Python working on my MBP with Mac OS
&lt;br&gt;10.5, since I need it to compile the chemical modeling software
&lt;br&gt;&amp;quot;AVOGADRO&amp;quot; for modification reasons.
&lt;br&gt;I pretty much followed the instructions on both the Boost, Getting
&lt;br&gt;Started guide and the Boost.Python Introduction. I managed to get the
&lt;br&gt;&amp;quot;Lambda&amp;quot; and the &amp;quot;Regex&amp;quot; examples working perfectly, but unfortunatly
&lt;br&gt;not the python &amp;quot;embedding&amp;quot; and &amp;quot;extending&amp;quot; examples, neither as well
&lt;br&gt;the &amp;quot;hello world&amp;quot;. Apparently, no
&lt;br&gt;embedding/extending module is being built for me to import in the
&lt;br&gt;python-test script following the build.
&lt;br&gt;My setup is as follows:
&lt;br&gt;&lt;br&gt;Boost root: /usr/local/boost_1_40_0/ (so I call every command with sudo).
&lt;br&gt;&lt;br&gt;The lambda and regex example files (.cpp) were perfectly compiling in a
&lt;br&gt;directory ~/programming_tests/, so my compiler is very likely to work.
&lt;br&gt;In order to do so, I issued the command:
&lt;br&gt;&lt;br&gt;cpp+ -I example.cpp -o example
&lt;br&gt;/usr/local/boost_1_40_0/lib/libboost_regex-mt.a
&lt;br&gt;&lt;br&gt;for some (possibly to the overall problem related) reason, it does not
&lt;br&gt;work with the dynamic
&lt;br&gt;library .dylib.
&lt;br&gt;&lt;br&gt;&lt;br&gt;What would be the basic procedure to get the boost.python examples
&lt;br&gt;running on Mac OS X?
&lt;br&gt;Thanks a lot for any suggestions.
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26477173&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Getting-Boost.Python-Working-on-MacOS-X-tp26477173p26477173.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26466990</id>
	<title>multithreading and interpreters</title>
	<published>2009-11-22T08:55:38Z</published>
	<updated>2009-11-22T08:55:38Z</updated>
	<author>
		<name>Trigve</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;I'm working on project where we used boost.python (embedded).
&lt;br&gt;&lt;br&gt;In general I have the &amp;quot;modules&amp;quot; where each module is something like sandbox, is
&lt;br&gt;isolated from others modules and run in solo thread. I want to be able to use 
&lt;br&gt;python (and boost python functions of course) from each module thread. Something
&lt;br&gt;like that each thread could have own interpreter without need to take care of GIL and
&lt;br&gt;like. Is it possible? I know there could be some problems with GIL and so. I've found in 
&lt;br&gt;python C API docs Py_NewInterpreter() function which could be of help (or not?).
&lt;br&gt;&lt;br&gt;So will this configuration work? Could be there some problems with boost.python
&lt;br&gt;when using multiple threads?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;Trigve
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26466990&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/multithreading-and-interpreters-tp26466990p26466990.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26459384</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-21T11:05:04Z</published>
	<updated>2009-11-21T11:05:04Z</updated>
	<author>
		<name>Roman Yakovenko</name>
	</author>
	<content type="html">On Fri, Nov 20, 2009 at 10:44 PM, Stefan Seefeld &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26459384&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;seefeld@...&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; Now I'm sure I've interpreted &amp;quot;scoping conversion operators&amp;quot; differently
&lt;br&gt;&amp;gt;&amp;gt; than you meant it.  Can you clarify?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; This is mostly only hand-waving, sorry. I was wondering whether it was
&lt;br&gt;&amp;gt; possible to make the registry not an application-global object, but a
&lt;br&gt;&amp;gt; per-module object. And if that's possible (and thus, conversions are by
&lt;br&gt;&amp;gt; default only available to the defining module), would it be possible to
&lt;br&gt;&amp;gt; chain them explicitly, to get both, well-defined semantics, as well as no
&lt;br&gt;&amp;gt; ODR violations.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I haven't thought about whether this has to involve runtime overhead, and if
&lt;br&gt;&amp;gt; so, how much. At least without the chaining it may actually be cheap. (Just
&lt;br&gt;&amp;gt; hide the registry symbol from other modules.)
&lt;br&gt;&amp;gt; And even with chaining, this is merely a lookup in a chain of converter
&lt;br&gt;&amp;gt; maps, which likely can be reordered / optimized at the point where one
&lt;br&gt;&amp;gt; registry is explicitly added to another.
&lt;br&gt;&amp;gt; Still, this is just a rough idea. I don't have any implementation ideas yet.
&lt;/div&gt;&lt;br&gt;IMHO, this could be the way to go. I already meat this problem in the past:
&lt;br&gt;* std containers were exposed using different suites
&lt;br&gt;* during the testing - initially all my tests run in the same process,
&lt;br&gt;but after 30 tests it became very difficult to name C++ classes :-),
&lt;br&gt;so I was forced to run every test in its own process.
&lt;br&gt;&lt;br&gt;The &amp;quot;per-module&amp;quot; registry could be a solution to the problem.
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Roman Yakovenko
&lt;br&gt;C++ Python language binding
&lt;br&gt;&lt;a href=&quot;http://www.language-binding.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.language-binding.net/&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26459384&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26459384.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26450625</id>
	<title>Re: Boost.Python + OpenGL segmentation faults</title>
	<published>2009-11-20T13:34:17Z</published>
	<updated>2009-11-20T13:34:17Z</updated>
	<author>
		<name>Mohan Ganesalingam</name>
	</author>
	<content type="html">&amp;gt; Back in 2005/2006 all that worked even with PyOpenGL imported under 
&lt;br&gt;&amp;gt; Windows.
&lt;br&gt;&lt;br&gt;I'm using boost 1.39 to embed Python 2.6 + PyOpenGL 3 in MSVC 2008 under 
&lt;br&gt;Windows XP right now, without any difficulties. I'm not using PyOpenGL 
&lt;br&gt;directly from C++, but have all the relevant code in a file pygl.py, and 
&lt;br&gt;run
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exec(&amp;quot;from pygl import *&amp;quot;);
&lt;br&gt;&lt;br&gt;in my C++ code. I'm not sure if any of this is helpful, but you're very 
&lt;br&gt;welcome to the code samples if they would be of any use.
&lt;br&gt;&lt;br&gt;Best wishes,
&lt;br&gt;Mohan
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26450625&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Efficient-string-passing-tp26425406p26450625.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26450049</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T12:44:19Z</published>
	<updated>2009-11-20T12:44:19Z</updated>
	<author>
		<name>Stefan Seefeld</name>
	</author>
	<content type="html">On 11/20/2009 03:23 PM, troy d. straszheim wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; For example, what does 'replaceable' mean ? Does it mean two bindings 
&lt;br&gt;&amp;gt;&amp;gt; are identical or equivalent ? 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; No it means only that the behavior in the situation above is modified.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Does it merely mean the user allows the mapping to change? (This 
&lt;br&gt;&amp;gt;&amp;gt; would lead into undefined behavior, if you don't carefully control in 
&lt;br&gt;&amp;gt;&amp;gt; which order things are loaded / initialized.)
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; UB as in what happens when there is an ODR violation? &amp;nbsp;How?
&lt;/div&gt;&lt;br&gt;I'm only talking about user-visible behavior, and assuming that it could 
&lt;br&gt;be implemented in a way that would avoid ODR violations.
&lt;br&gt;(Whether that's actually possible is a different matter. I'm only 
&lt;br&gt;talking about semantics.)
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; A different approach might be to avoid collisions by 'scoping' 
&lt;br&gt;&amp;gt;&amp;gt; conversion operators, so they are only available to specific 
&lt;br&gt;&amp;gt;&amp;gt; extension modules. 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Interesting idea. &amp;nbsp;As I interpret &amp;quot;scoping conversion operators&amp;quot;, I'm 
&lt;br&gt;&amp;gt; not sure the cost in runtime and complexity would be worth it, OTOH I 
&lt;br&gt;&amp;gt; don't have much to go on here.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &amp;gt; May a converter registry be explicitly imported into a module,
&lt;br&gt;&amp;gt;&amp;gt; during initialization?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Now I'm sure I've interpreted &amp;quot;scoping conversion operators&amp;quot; 
&lt;br&gt;&amp;gt; differently than you meant it. &amp;nbsp;Can you clarify?
&lt;/div&gt;&lt;br&gt;This is mostly only hand-waving, sorry. I was wondering whether it was 
&lt;br&gt;possible to make the registry not an application-global object, but a 
&lt;br&gt;per-module object. And if that's possible (and thus, conversions are by 
&lt;br&gt;default only available to the defining module), would it be possible to 
&lt;br&gt;chain them explicitly, to get both, well-defined semantics, as well as 
&lt;br&gt;no ODR violations.
&lt;br&gt;&lt;br&gt;I haven't thought about whether this has to involve runtime overhead, 
&lt;br&gt;and if so, how much. At least without the chaining it may actually be 
&lt;br&gt;cheap. (Just hide the registry symbol from other modules.)
&lt;br&gt;And even with chaining, this is merely a lookup in a chain of converter 
&lt;br&gt;maps, which likely can be reordered / optimized at the point where one 
&lt;br&gt;registry is explicitly added to another.
&lt;br&gt;Still, this is just a rough idea. I don't have any implementation ideas yet.
&lt;br&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; That would involve making dependency between extension modules 
&lt;br&gt;&amp;gt;&amp;gt; explicit (&amp;quot;module X imports converters provided by module Y&amp;quot;). 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; But, you can do that now; &amp;quot;module X imports the converter for T 
&lt;br&gt;&amp;gt; provided by module Y&amp;quot; just means &amp;quot;module X doesn't wrap T and won't 
&lt;br&gt;&amp;gt; run without Y&amp;quot;, right?
&lt;br&gt;&lt;br&gt;Yes. I'm talking about the case where module X and module Y provide a 
&lt;br&gt;converter for T, so the user who wishes to use X and Y needs to specify 
&lt;br&gt;the desired behavior, which could be &amp;quot;each uses its own&amp;quot; or &amp;quot;either of 
&lt;br&gt;the two will be used globally&amp;quot;.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Stefan
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...ich hab' noch einen Koffer in Berlin...
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26450049&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26450049.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26449729</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T12:23:43Z</published>
	<updated>2009-11-20T12:23:43Z</updated>
	<author>
		<name>troy d. straszheim</name>
	</author>
	<content type="html">Stefan Seefeld wrote:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; It's an interesting thought, but it raises a lot of questions, and opens 
&lt;br&gt;&amp;gt; a huge can of worms. (Welcome in the world of 'DLL hell' !)
&lt;br&gt;&amp;gt; I'm not sure what angle to attack this problem from. In particular, I 
&lt;br&gt;&amp;gt; believe before thinking about interface issues, we should clarify the 
&lt;br&gt;&amp;gt; problem domain, and in particular, what semantics we want.
&lt;br&gt;&lt;br&gt;I thought this was obvious, sorry. &amp;nbsp;The 'worst' and most common scenario 
&lt;br&gt;is, precisely put: &amp;nbsp;more than one python extension module over which we 
&lt;br&gt;have no control has wrapped type T. &amp;nbsp;We need to use them simultaneously. 
&lt;br&gt;&amp;nbsp; For instance, here are two modules that both wrap vector&amp;lt;double&amp;gt;. 
&lt;br&gt;With assertions enabled, this happens:
&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import converter_collisions1_ext
&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import converter_collisions2_ext
&lt;br&gt;python: 
&lt;br&gt;/home/troy/Projects/boost/src/libs/python/src/converter/registry.cpp:212: 
&lt;br&gt;void boost::python::converter::registry::insert(PyObject* (*)(const 
&lt;br&gt;void*), boost::python::type_info, const PyTypeObject* (*)()): Assertion 
&lt;br&gt;`slot-&amp;gt;m_to_python == 0' failed.
&lt;br&gt;zsh: abort &amp;nbsp; &amp;nbsp; &amp;nbsp;python
&lt;br&gt;&lt;br&gt;&lt;br&gt;delightfully, without assertions there is only a warning:
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import converter_collisions1_ext
&lt;br&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import converter_collisions2_ext
&lt;br&gt;__main__:1: RuntimeWarning: to-Python converter for std::vector&amp;lt;double, 
&lt;br&gt;std::allocator&amp;lt;double&amp;gt; &amp;gt; already registered; second conversion method 
&lt;br&gt;ignored.
&lt;br&gt;&lt;br&gt;&lt;br&gt;So one resolution is to remove the 'assert' that triggers this crash and 
&lt;br&gt;leave the semantics as-is: &amp;nbsp;second and later converter registrations are 
&lt;br&gt;warned about and ignored. &amp;nbsp; I'm simply suggesting we give the user more 
&lt;br&gt;control over this behavior, because in a number of situations (it is up 
&lt;br&gt;to the user to determine what they are) such control would be useful.
&lt;br&gt;&lt;br&gt;&amp;gt; For example, what does 'replaceable' mean ? Does it mean two bindings 
&lt;br&gt;&amp;gt; are identical or equivalent ? 
&lt;br&gt;&lt;br&gt;No it means only that the behavior in the situation above is modified.
&lt;br&gt;&lt;br&gt;&amp;gt; Does it merely mean the user allows the 
&lt;br&gt;&amp;gt; mapping to change? (This would lead into undefined behavior, if you 
&lt;br&gt;&amp;gt; don't carefully control in which order things are loaded / initialized.)
&lt;br&gt;&lt;br&gt;UB as in what happens when there is an ODR violation? &amp;nbsp;How?
&lt;br&gt;&lt;br&gt;&amp;gt; A different approach might be to avoid collisions by 'scoping' 
&lt;br&gt;&amp;gt; conversion operators, so they are only available to specific extension 
&lt;br&gt;&amp;gt; modules. 
&lt;br&gt;&lt;br&gt;Interesting idea. &amp;nbsp;As I interpret &amp;quot;scoping conversion operators&amp;quot;, I'm 
&lt;br&gt;not sure the cost in runtime and complexity would be worth it, OTOH I 
&lt;br&gt;don't have much to go on here.
&lt;br&gt;&lt;br&gt;&amp;nbsp;&amp;gt; May a converter registry be explicitly imported into a module,
&lt;br&gt;&amp;gt; during initialization?
&lt;br&gt;&lt;br&gt;Now I'm sure I've interpreted &amp;quot;scoping conversion operators&amp;quot; differently 
&lt;br&gt;than you meant it. &amp;nbsp;Can you clarify?
&lt;br&gt;&lt;br&gt;&amp;gt; That would involve making dependency between extension modules explicit 
&lt;br&gt;&amp;gt; (&amp;quot;module X imports converters provided by module Y&amp;quot;). 
&lt;br&gt;&lt;br&gt;But, you can do that now; &amp;quot;module X imports the converter for T provided 
&lt;br&gt;by module Y&amp;quot; just means &amp;quot;module X doesn't wrap T and won't run without 
&lt;br&gt;Y&amp;quot;, right?
&lt;br&gt;&lt;br&gt;-t
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26449729&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26449729.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26447362</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T09:29:27Z</published>
	<updated>2009-11-20T09:29:27Z</updated>
	<author>
		<name>Stefan Seefeld</name>
	</author>
	<content type="html">On 11/20/2009 11:47 AM, troy d. straszheim wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Stefan Seefeld wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; (It's a global symbol that is seen by all DSOs. Having two DSOs
&lt;br&gt;&amp;gt;&amp;gt; provide that symbol, but with different content, is illegal.)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'd like to fix this, now, it is starting to cause me pain.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; For instance, it also rears its ugly head if you import two libraries
&lt;br&gt;&amp;gt; that both wrap std::vector&amp;lt;double&amp;gt;, for instance if you try to use the 
&lt;br&gt;&amp;gt; IceTray physics analysis suite together with Paul Kunz's wonderful 
&lt;br&gt;&amp;gt; Hippodraw.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Another situation that came up recently was that the pair&amp;lt;T,U&amp;gt; inside 
&lt;br&gt;&amp;gt; std::map&amp;lt;T, U&amp;gt; and another container of T,U (that used pair&amp;lt;T,U&amp;gt; 
&lt;br&gt;&amp;gt; internally) collided. &amp;nbsp;I think it should be possible to specify that a 
&lt;br&gt;&amp;gt; type's wrapper is replaceable (if you know, for instance, that two 
&lt;br&gt;&amp;gt; projects wrap std::pair&amp;lt;string,int&amp;gt; the same way).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I haven't thought about the interface much yet.
&lt;/div&gt;&lt;br&gt;It's an interesting thought, but it raises a lot of questions, and opens 
&lt;br&gt;a huge can of worms. (Welcome in the world of 'DLL hell' !)
&lt;br&gt;I'm not sure what angle to attack this problem from. In particular, I 
&lt;br&gt;believe before thinking about interface issues, we should clarify the 
&lt;br&gt;problem domain, and in particular, what semantics we want.
&lt;br&gt;&lt;br&gt;For example, what does 'replaceable' mean ? Does it mean two bindings 
&lt;br&gt;are identical or equivalent ? Does it merely mean the user allows the 
&lt;br&gt;mapping to change ? (This would lead into undefined behavior, if you 
&lt;br&gt;don't carefully control in which order things are loaded / initialized.)
&lt;br&gt;&lt;br&gt;A different approach might be to avoid collisions by 'scoping' 
&lt;br&gt;conversion operators, so they are only available to specific extension 
&lt;br&gt;modules. May a converter registry be explicitly imported into a module, 
&lt;br&gt;during initialization ?
&lt;br&gt;That would involve making dependency between extension modules explicit 
&lt;br&gt;(&amp;quot;module X imports converters provided by module Y&amp;quot;). In general, I 
&lt;br&gt;think that would be cleanest. &amp;quot;Explicit is better than implicit.&amp;quot; I'm 
&lt;br&gt;sure David would like that. ;-)
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Stefan
&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...ich hab' noch einen Koffer in Berlin...
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26447362&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26447362.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26446892</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T08:47:09Z</published>
	<updated>2009-11-20T08:47:09Z</updated>
	<author>
		<name>troy d. straszheim</name>
	</author>
	<content type="html">Stefan Seefeld wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; On 11/20/2009 05:50 AM, Eilif Mueller wrote:
&lt;br&gt;&amp;gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I'm using boost.python to interface with some dynamically generated
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;C++ code, employing some scipy.weave facilities to cache the
&lt;br&gt;&amp;gt;&amp;gt; results. When I force a recompile and import, I get the following
&lt;br&gt;&amp;gt;&amp;gt; message:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; RuntimeWarning: to-Python converter for __randint already
&lt;br&gt;&amp;gt;&amp;gt; registered; second conversion method ignored.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; where __randint is the dynamically generated class. &amp;nbsp;As such, the 
&lt;br&gt;&amp;gt;&amp;gt; changes to the code (__randint) are not represented in the newly 
&lt;br&gt;&amp;gt;&amp;gt; imported module.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Is it possible to override this behaviour so that the new class 
&lt;br&gt;&amp;gt;&amp;gt; replaces the registration for the old one?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I very much doubt that what you want is possible: All extension
&lt;br&gt;&amp;gt; modules using boost.python share a single global 'registry' that
&lt;br&gt;&amp;gt; holds type-conversion information. Thus it is impossible to have that
&lt;br&gt;&amp;gt; loaded while a separate process is adding new entries to it.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; (It's a global symbol that is seen by all DSOs. Having two DSOs
&lt;br&gt;&amp;gt; provide that symbol, but with different content, is illegal.)
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;I'd like to fix this, now, it is starting to cause me pain.
&lt;br&gt;&lt;br&gt;For instance, it also rears its ugly head if you import two libraries
&lt;br&gt;that both wrap std::vector&amp;lt;double&amp;gt;, for instance if you try to use the 
&lt;br&gt;IceTray physics analysis suite together with Paul Kunz's wonderful 
&lt;br&gt;Hippodraw.
&lt;br&gt;&lt;br&gt;Another situation that came up recently was that the pair&amp;lt;T,U&amp;gt; inside 
&lt;br&gt;std::map&amp;lt;T, U&amp;gt; and another container of T,U (that used pair&amp;lt;T,U&amp;gt; 
&lt;br&gt;internally) collided. &amp;nbsp;I think it should be possible to specify that a 
&lt;br&gt;type's wrapper is replaceable (if you know, for instance, that two 
&lt;br&gt;projects wrap std::pair&amp;lt;string,int&amp;gt; the same way).
&lt;br&gt;&lt;br&gt;I haven't thought about the interface much yet. &amp;nbsp;Here's something I just 
&lt;br&gt;decided against, a per-type global 'replacability' flag, that warns or &amp;nbsp;not:
&lt;br&gt;&lt;br&gt;template &amp;lt;typename T&amp;gt;
&lt;br&gt;void replacable&amp;lt;T&amp;gt;(bool quietly);
&lt;br&gt;&lt;br&gt;BOOST_PYTHON_MODULE(mymod)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;replacable&amp;lt;std::pair&amp;lt;string,int&amp;gt; &amp;gt;(true);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;But this doesn't help the situation where you're trying to use two
&lt;br&gt;different python modules together, neither of which specifies that pairs
&lt;br&gt;are replacable. &amp;nbsp;It seems that boost.python should expose some
&lt;br&gt;way to specify replacability at runtime. &amp;nbsp;How about this. &amp;nbsp;A type's 
&lt;br&gt;converters are 'locked', 'verbose', and 'nonthrowing' by default (like 
&lt;br&gt;they are now).
&lt;br&gt;Boost python modules expose one function
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;def __lock__(type, lock, verbose, throw): ...
&lt;br&gt;&lt;br&gt;at module scope that allows you to specify whether
&lt;br&gt;&lt;br&gt;- types are locked down or replacable
&lt;br&gt;- collisions should be complained about to stdout
&lt;br&gt;- collision events should throw
&lt;br&gt;&lt;br&gt;e.g.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import M1
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;# silently replace T's
&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt;&amp;gt; M1.__lock__(M1.T, lock=False, verbose=False, throw=False)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;# verbosely refuse replacement of tees
&lt;br&gt;&amp;nbsp; &amp;nbsp;&amp;gt;&amp;gt;&amp;gt; M1.__lock__(M1.T, lock=True, verbose=True, throw=False)
&lt;br&gt;&lt;br&gt;And that this __lock__ function would also be available on the C++ side
&lt;br&gt;for setting defaults:
&lt;br&gt;&lt;br&gt;BOOST_PYTHON_MODULE(M1)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;class_&amp;lt;T&amp;gt;(&amp;quot;T&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;...
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;lock&amp;lt;T&amp;gt;(false, false, false); // silent, replacable, nonthrowing
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;Just a sketch. &amp;nbsp;Thoughts?
&lt;br&gt;&lt;br&gt;-t
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26446892&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26446892.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26442946</id>
	<title>Re: dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T05:00:56Z</published>
	<updated>2009-11-20T05:00:56Z</updated>
	<author>
		<name>Stefan Seefeld</name>
	</author>
	<content type="html">On 11/20/2009 05:50 AM, Eilif Mueller wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm using boost.python to interface with some dynamically generated C++ code, employing some scipy.weave facilities to cache the results. &amp;nbsp;When I force a recompile and import, I get the following message:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; RuntimeWarning: to-Python converter for __randint already registered; second conversion method ignored.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; where __randint is the dynamically generated class. &amp;nbsp;As such, the changes to the code (__randint) are not represented in the newly imported module.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is it possible to override this behaviour so that the new class replaces the registration for the old one?
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;
&lt;/div&gt;&lt;br&gt;I very much doubt that what you want is possible: All extension modules 
&lt;br&gt;using boost.python share a single global 'registry' that holds 
&lt;br&gt;type-conversion information. Thus it is impossible to have that loaded 
&lt;br&gt;while a separate process is adding new entries to it.
&lt;br&gt;&lt;br&gt;(It's a global symbol that is seen by all DSOs. Having two DSOs provide 
&lt;br&gt;that symbol, but with different content, is illegal.)
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Stefan
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...ich hab' noch einen Koffer in Berlin...
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26442946&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26442946.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26442360</id>
	<title>dynamic compile and &quot;to-Python converter ... second conversion method ignored&quot;</title>
	<published>2009-11-20T02:50:01Z</published>
	<updated>2009-11-20T02:50:01Z</updated>
	<author>
		<name>Eilif Mueller</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I'm using boost.python to interface with some dynamically generated C++ code, employing some scipy.weave facilities to cache the results. &amp;nbsp;When I force a recompile and import, I get the following message:
&lt;br&gt;&lt;br&gt;RuntimeWarning: to-Python converter for __randint already registered; second conversion method ignored.
&lt;br&gt;&lt;br&gt;where __randint is the dynamically generated class. &amp;nbsp;As such, the changes to the code (__randint) are not represented in the newly imported module. 
&lt;br&gt;&lt;br&gt;Is it possible to override this behaviour so that the new class replaces the registration for the old one?
&lt;br&gt;&lt;br&gt;Thanks.
&lt;br&gt;&lt;br&gt;cheers,
&lt;br&gt;&lt;br&gt;Eilif
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
&lt;br&gt;Jetzt freischalten unter &lt;a href=&quot;http://portal.gmx.net/de/go/maxdome01&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://portal.gmx.net/de/go/maxdome01&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26442360&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/dynamic-compile-and-%22to-Python-converter-...-second-conversion-method-ignored%22-tp26442360p26442360.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26436972</id>
	<title>Re: Boost.Python + OpenGL segmentation faults</title>
	<published>2009-11-19T17:02:37Z</published>
	<updated>2009-11-19T17:02:37Z</updated>
	<author>
		<name>Ralf W. Grosse-Kunstleve</name>
	</author>
	<content type="html">Just a remark:
&lt;br&gt;We are heavily using Boost.Python extensions together with OpenGL, and have so for years.
&lt;br&gt;It works for us without problems under Windows, Mac OS X, Linux.
&lt;br&gt;We are not using PyOpenGL, though, but have our own Boost.Python-based wrappers for the
&lt;br&gt;entire OpenGL library (&lt;a href=&quot;http://cci.lbl.gov/gltbx/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://cci.lbl.gov/gltbx/&lt;/a&gt;).
&lt;br&gt;Back in 2005/2006 all that worked even with PyOpenGL imported under Windows.
&lt;br&gt;&lt;br&gt;I'd try running with valgrind to debug.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;----- Original Message ----
&lt;br&gt;From: Dimitri Tcaciuc &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26436972&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;dtcaciuc@...&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26436972&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;Sent: Thu, November 19, 2009 1:54:51 PM
&lt;br&gt;Subject: [C++-sig] Boost.Python + OpenGL segmentation faults
&lt;br&gt;&lt;br&gt;Hello everyone,
&lt;br&gt;&lt;br&gt;I've recently posted a problem to SO
&lt;br&gt;(&lt;a href=&quot;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&lt;/a&gt;),
&lt;br&gt;where I haven't had much luck with answer.
&lt;br&gt;&lt;br&gt;My problem is that if I import OpenGL python libraries before
&lt;br&gt;importing my B.P bindings, I get strange segmentation faults for no
&lt;br&gt;apparent reason. I isolated a small test case which I'm attaching
&lt;br&gt;below. The current boost library version I'm using is 1.37; you'll
&lt;br&gt;have to make a change to Makefile if you have any other version
&lt;br&gt;installed.
&lt;br&gt;&lt;br&gt;I'd greatly appreciate if anyone can give some insight on what's happening.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Dimitri.
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26436972&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Boost.Python-%2B-OpenGL-segmentation-faults-tp26434815p26436972.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26435076</id>
	<title>Re: Boost.Python + OpenGL segmentation faults</title>
	<published>2009-11-19T14:13:26Z</published>
	<updated>2009-11-19T14:13:26Z</updated>
	<author>
		<name>troy d. straszheim</name>
	</author>
	<content type="html">Dimitri Tcaciuc wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hello everyone,
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I've recently posted a problem to SO
&lt;br&gt;&amp;gt; (&lt;a href=&quot;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&lt;/a&gt;),
&lt;br&gt;&amp;gt; where I haven't had much luck with answer.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; My problem is that if I import OpenGL python libraries before
&lt;br&gt;&amp;gt; importing my B.P bindings, I get strange segmentation faults for no
&lt;br&gt;&amp;gt; apparent reason. I isolated a small test case which I'm attaching
&lt;br&gt;&amp;gt; below. The current boost library version I'm using is 1.37; you'll
&lt;br&gt;&amp;gt; have to make a change to Makefile if you have any other version
&lt;br&gt;&amp;gt; installed.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I'd greatly appreciate if anyone can give some insight on what's happening.
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;The only thing that strikes me is that I'd just use the 
&lt;br&gt;vector_indexing_suite on the 'vector&amp;lt;A::ptr&amp;gt; elements'.
&lt;br&gt;&lt;br&gt;Beyond that, the next thing you'd want is a --with-pydebug 
&lt;br&gt;--without-pymalloc build of python (with associated opengl and 
&lt;br&gt;boost.python built against this library), get some stacktraces from 
&lt;br&gt;running under gdb, and run things under valgrind with the 
&lt;br&gt;valgrind-python.supp list from the Misc directory of the python 
&lt;br&gt;distribution. &amp;nbsp;It is a bit of work to set up but you get a lot more 
&lt;br&gt;debuggability.
&lt;br&gt;&lt;br&gt;-t
&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26435076&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Boost.Python-%2B-OpenGL-segmentation-faults-tp26434815p26435076.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26434815</id>
	<title>Boost.Python + OpenGL segmentation faults</title>
	<published>2009-11-19T13:54:51Z</published>
	<updated>2009-11-19T13:54:51Z</updated>
	<author>
		<name>Dimitri Tcaciuc</name>
	</author>
	<content type="html">Hello everyone,
&lt;br&gt;&lt;br&gt;I've recently posted a problem to SO
&lt;br&gt;(&lt;a href=&quot;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://stackoverflow.com/questions/1751408/boost-python-opengl-segmentation-faults&lt;/a&gt;),
&lt;br&gt;where I haven't had much luck with answer.
&lt;br&gt;&lt;br&gt;My problem is that if I import OpenGL python libraries before
&lt;br&gt;importing my B.P bindings, I get strange segmentation faults for no
&lt;br&gt;apparent reason. I isolated a small test case which I'm attaching
&lt;br&gt;below. The current boost library version I'm using is 1.37; you'll
&lt;br&gt;have to make a change to Makefile if you have any other version
&lt;br&gt;installed.
&lt;br&gt;&lt;br&gt;I'd greatly appreciate if anyone can give some insight on what's happening.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Dimitri.
&lt;br&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26434815&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;foo.cpp&lt;/strong&gt; (2K) &lt;a href=&quot;http://old.nabble.com/attachment/26434815/0/foo.cpp&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;glcrash.py&lt;/strong&gt; (254 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26434815/1/glcrash.py&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;br/&gt;&lt;img src=&quot;http://old.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;Makefile&lt;/strong&gt; (192 bytes) &lt;a href=&quot;http://old.nabble.com/attachment/26434815/2/Makefile&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Boost.Python-%2B-OpenGL-segmentation-faults-tp26434815p26434815.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26426759</id>
	<title>Re: Efficient string passing</title>
	<published>2009-11-19T05:56:39Z</published>
	<updated>2009-11-19T05:56:39Z</updated>
	<author>
		<name>Stefan Seefeld</name>
	</author>
	<content type="html">On 11/19/2009 08:30 AM, Mohan Ganesalingam wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; I believe this is impossible: Python treats strings as immutable, 
&lt;br&gt;&amp;gt;&amp;gt; which means you can't manipulate them in-place, and there is no C API 
&lt;br&gt;&amp;gt;&amp;gt; function 
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; There is apparently one exception to this, which I was utilising:
&lt;br&gt;&amp;gt; char* PyString_AsString(PyObject *string) Returns a NUL-terminated 
&lt;br&gt;&amp;gt; representation of the contents of string. The pointer refers to the 
&lt;br&gt;&amp;gt; internal buffer of string, not a copy. The data must not be modified 
&lt;br&gt;&amp;gt; in any way, unless the string was just created using 
&lt;br&gt;&amp;gt; PyString_FromStringAndSize(NULL, size).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I.e. if you create a string using PyString_FromStringAndSize(0, n), 
&lt;br&gt;&amp;gt; then you can immediately modify its contents using PyString_AsString. 
&lt;br&gt;&amp;gt; AFAICS this functionality is (reasonably enough) not wrapped by 
&lt;br&gt;&amp;gt; boost::python::str, so you have to use the underlying API.
&lt;/div&gt;&lt;br&gt;OK, perhaps I misunderstood your use-case. Indeed, you may allocate a 
&lt;br&gt;string using the Python C API, and have a small window within which you 
&lt;br&gt;can manipulate its content, before handing control back to the Python 
&lt;br&gt;runtime. If that is what you need, great.
&lt;br&gt;&lt;br&gt;For avoidance of doubt: I don't think it would be valid to modify that 
&lt;br&gt;string after you have handed control back to Python. The Python runtime 
&lt;br&gt;may well create hashes from it for efficient lookup, which build on the 
&lt;br&gt;immutability of this type of object.
&lt;br&gt;&lt;br&gt;Regards,
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Stefan
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...ich hab' noch einen Koffer in Berlin...
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26426759&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Efficient-string-passing-tp26425406p26426759.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26426454</id>
	<title>Re: Efficient string passing</title>
	<published>2009-11-19T05:30:45Z</published>
	<updated>2009-11-19T05:30:45Z</updated>
	<author>
		<name>Mohan Ganesalingam</name>
	</author>
	<content type="html">Thank you for the reply! As you spotted, I was making an embarrassingly 
&lt;br&gt;idiotic typo (due to too much cut and pasting)... it should of course have 
&lt;br&gt;been
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handle&amp;lt;&amp;gt; h(result);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return object(h);
&lt;br&gt;&lt;br&gt;Once that was fixed, everything worked fine. 
&lt;br&gt;&lt;br&gt;&amp;gt;I believe this is impossible: Python treats strings as immutable, which 
&lt;br&gt;&amp;gt;means you can't manipulate them in-place, and there is no C API function 
&lt;br&gt;&lt;br&gt;There is apparently one exception to this, which I was utilising: 
&lt;br&gt;&lt;br&gt;char* PyString_AsString(PyObject *string) Returns a NUL-terminated 
&lt;br&gt;representation of the contents of string. The pointer refers to the 
&lt;br&gt;internal buffer of string, not a copy. The data must not be modified in any 
&lt;br&gt;way, unless the string was just created using 
&lt;br&gt;PyString_FromStringAndSize(NULL, size).
&lt;br&gt;&lt;br&gt;I.e. if you create a string using PyString_FromStringAndSize(0, n), then 
&lt;br&gt;you can immediately modify its contents using PyString_AsString. AFAICS 
&lt;br&gt;this functionality is (reasonably enough) not wrapped by 
&lt;br&gt;boost::python::str, so you have to use the underlying API.
&lt;br&gt;&lt;br&gt;Thanks again for spotting that!
&lt;br&gt;&lt;br&gt;Best wishes,
&lt;br&gt;Mohan
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26426454&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Efficient-string-passing-tp26425406p26426454.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26425922</id>
	<title>Re: Efficient string passing</title>
	<published>2009-11-19T05:06:07Z</published>
	<updated>2009-11-19T05:06:07Z</updated>
	<author>
		<name>Stefan Seefeld</name>
	</author>
	<content type="html">On 11/19/2009 07:30 AM, Mohan Ganesalingam wrote:
&lt;br&gt;&amp;gt; Dear all,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I recently sent an e-mail which (I think) didn't reach the list, about 
&lt;br&gt;&amp;gt; trying to return large strings from C++ into Python without copying them.
&lt;br&gt;&lt;br&gt;I believe this is impossible: Python treats strings as immutable, which 
&lt;br&gt;means you can't manipulate them in-place, and there is no C API function 
&lt;br&gt;that allows you to pass in a string by reference, as that would make 
&lt;br&gt;memory management impossibly complex.
&lt;br&gt;&lt;br&gt;&amp;gt; By looking at the C/Python API I've subsequently figured out roughly 
&lt;br&gt;&amp;gt; how to do this... something like
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Class World
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; object return_object()
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PyObject *result = PyString_FromStringAndSize(0, 7);
&lt;br&gt;&lt;br&gt;This creates a new string, copying whatever you pass as input.
&lt;br&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initialise the underlying string using PyString_AsString 
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handle&amp;lt;&amp;gt; h(result);
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return object();
&lt;br&gt;&lt;br&gt;I'm not sure what your intent is, but returning a default-constructed 
&lt;br&gt;object is the C++ equivalent of None.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; ...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; main_namespace[&amp;quot;World&amp;quot;] = class_&amp;lt;World&amp;gt;(&amp;quot;World&amp;quot;)
&lt;br&gt;&amp;gt; .def(&amp;quot;return_object&amp;quot;, &amp;World::return_object);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Unfortunately this doesn't work; when I call w.return_object(), I get 
&lt;br&gt;&amp;gt; back None.
&lt;/div&gt;&lt;br&gt;...because above you &amp;quot;return object();&amp;quot;, presumably.
&lt;br&gt;&lt;br&gt;&amp;gt; Returning a raw PyObject * instead of a boost::python::object works, 
&lt;br&gt;&amp;gt; but I can't tell if that involves a copy... and using 
&lt;br&gt;&amp;gt; return_value_policy&amp;lt;manage_new_object&amp;gt;() with a PyObject * return 
&lt;br&gt;&amp;gt; crashes.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any advice here would be very much appreciated!
&lt;br&gt;&lt;br&gt;I don't think you can get what you want using strings directly. You may 
&lt;br&gt;create and expose a wrapper type that provides a string-like interface, 
&lt;br&gt;with appropriate conversions.
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Stefan
&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...ich hab' noch einen Koffer in Berlin...
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26425922&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Efficient-string-passing-tp26425406p26425922.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26425406</id>
	<title>Efficient string passing</title>
	<published>2009-11-19T04:30:16Z</published>
	<updated>2009-11-19T04:30:16Z</updated>
	<author>
		<name>Mohan Ganesalingam</name>
	</author>
	<content type="html">Dear all,
&lt;br&gt;&lt;br&gt;I recently sent an e-mail which (I think) didn't reach the list, about 
&lt;br&gt;trying to return large strings from C++ into Python without copying them. 
&lt;br&gt;By looking at the C/Python API I've subsequently figured out roughly how to 
&lt;br&gt;do this... something like
&lt;br&gt;&lt;br&gt;Class World
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; object return_object()
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PyObject *result = PyString_FromStringAndSize(0, 7);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // initialise the underlying string using PyString_AsString 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handle&amp;lt;&amp;gt; h(result);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return object();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;...
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;main_namespace[&amp;quot;World&amp;quot;] = class_&amp;lt;World&amp;gt;(&amp;quot;World&amp;quot;)
&lt;br&gt;.def(&amp;quot;return_object&amp;quot;, &amp;World::return_object);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;Unfortunately this doesn't work; when I call w.return_object(), I get back 
&lt;br&gt;None. Returning a raw PyObject * instead of a boost::python::object works, 
&lt;br&gt;but I can't tell if that involves a copy... and using 
&lt;br&gt;return_value_policy&amp;lt;manage_new_object&amp;gt;() with a PyObject * return crashes.
&lt;br&gt;&lt;br&gt;Any advice here would be very much appreciated!
&lt;br&gt;&lt;br&gt;Thank you and best wishes,
&lt;br&gt;Mohan
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26425406&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Efficient-string-passing-tp26425406p26425406.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26291937</id>
	<title>[Boost.Python] tutorial python extension fails on import with ImportError: No module named hello_ext</title>
	<published>2009-11-10T13:36:41Z</published>
	<updated>2009-11-10T13:36:41Z</updated>
	<author>
		<name>Charles Lentz</name>
	</author>
	<content type="html">&lt;html xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot; xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot; xmlns:w=&quot;urn:schemas-microsoft-com:office:word&quot; xmlns:m=&quot;http://schemas.microsoft.com/office/2004/12/omml&quot; xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;

&lt;head&gt;
&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=us-ascii&quot;&gt;


&lt;meta name=Generator content=&quot;Microsoft Word 12 (filtered medium)&quot;&gt;

&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapedefaults v:ext=&quot;edit&quot; spidmax=&quot;1026&quot; /&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapelayout v:ext=&quot;edit&quot;&gt;
  &lt;o:idmap v:ext=&quot;edit&quot; data=&quot;1&quot; /&gt;
 &lt;/o:shapelayout&gt;&lt;/xml&gt;&lt;![endif]--&gt;
&lt;/head&gt;

&lt;body lang=EN-US link=blue vlink=purple&gt;

&lt;div class=Section1&gt;

&lt;p class=MsoNormal&gt;Hey all, &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;When using boost_1_38_0\libs\python\example\tutorial, I try
to import the extension that is created (hello_ext) but get the exception,
ImportError: No module named hello_ext&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;Here&amp;#8217;s some details that might be needed:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;OS: Windows Vista&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;Boost version: 1.38.0&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;Bjam version: 3.1.17&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;Python version: 2.6.2&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;My user-config.jam looks like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;#&amp;nbsp; MSVC configuration&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;using msvc : 9.0 ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;#&amp;nbsp; Python configuration&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;using python &lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; : 2.6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;#version&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; : C:/Python26&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#location&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; : C:/projects/external/python/Python-2.6.2/Include&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#includes&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; : C:/projects/external/python/Python-2.6.2/Lib&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
#libraries&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; ;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;I am working with the tutorial example located here:
boost_1_38_0\libs\python\example\tutorial.&amp;nbsp; When I run Bjam after I cd to
this directory, this tutorial example says that it passes all the tests and I
can check the output in the resulting files within the hello.test directory.&amp;nbsp;
That's all well and good that the test can get this extension module to work,
but I want to be able to import it myself in a python session or python
file.&amp;nbsp; That way I can see it work and then move on to creating my own
extensions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;I modify Jamroot so that the last few lines where it creates
tests are commented out.&amp;nbsp; When I run bjam again, hello_ext.pyd remains (previously
it was being created, used for the test, and then deleted).&amp;nbsp; I try to run
hello.py (which is the script that the test uses) from IDLE (which comes with
the installation of python) and it throws an exception for my import statement&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;Traceback (most recent call last):&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; File
&amp;quot;C:\Users\Charles\Desktop\boost_1_38_0\boost_1_38_0\libs\python\example\tutorial\hello.py&amp;quot;,
line 6, in &amp;lt;module&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import hello_ext&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;ImportError: No module named hello_ext&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;Hrmm.&amp;nbsp; Okay.&amp;nbsp; So I move the hello.py file into the
same directory as the hello_ext.pyd file.&amp;nbsp; Run it again using IDLE, still
get the exception&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;Traceback (most recent call last):&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp; File
&amp;quot;C:\Users\Charles\Desktop\boost_1_38_0\boost_1_38_0\libs\python\example\tutorial\bin\msvc-9.0\debug\threading-multi\hello.py&amp;quot;,
line 6, in &amp;lt;module&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import hello_ext&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;i&gt;ImportError: No module named hello_ext&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;So I guess I need some help here.&amp;nbsp; I want to be able to
create an extension module and then import it in a script.&amp;nbsp; This is what I
was led to believe I could do, but I do not see how.&amp;nbsp; I have tried to
provide all information that I think is necessary.&amp;nbsp; Any help is greatly
appreciated.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;/div&gt;

 &lt;BR&gt;&lt;BR&gt;__________ Information from ESET NOD32 Antivirus, version of virus signature database 4593 (20091110) __________&lt;BR&gt;&lt;BR&gt;The message was checked by ESET NOD32 Antivirus.&lt;BR&gt;&lt;BR&gt;&lt;A HREF=&quot;http://www.eset.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.eset.com&lt;/A&gt;&lt;BR&gt; &lt;/body&gt;

&lt;/html&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26291937&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/-Boost.Python--tutorial-python-extension-fails-on-import-with-ImportError%3A-No-module-named-hello_ext-tp26291937p26291937.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26283549</id>
	<title>Re: getting shape of numpy array</title>
	<published>2009-11-10T05:35:13Z</published>
	<updated>2009-11-10T05:35:13Z</updated>
	<author>
		<name>Michele De Stefano</name>
	</author>
	<content type="html">Hello Nathan.
&lt;br&gt;&lt;br&gt;Find my answers below.
&lt;br&gt;&lt;br&gt;2009/11/10 Nathan Huesken &amp;lt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26283549&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;boost-python@...&lt;/a&gt;&amp;gt;:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I am trying to interaface a numpy array using boost::python::numeric::array.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; void function(numeric::array&amp; a)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt;        tuple shape=extract&amp;lt;tuple&amp;gt;(a.getshape());
&lt;br&gt;&amp;gt;        double x;
&lt;br&gt;&amp;gt;        int i,j;
&lt;br&gt;&amp;gt;        for(i=0;i&amp;lt;shape[0];++i)
&lt;br&gt;&amp;gt;                for(j=0;j&amp;lt;shape[1];++j)
&lt;br&gt;&amp;gt;                        x=extract&amp;lt;double&amp;gt;(a[make_tuple(i,j)]);
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Now I had to add
&lt;br&gt;&amp;gt; numeric::array::set_module_and_type(&amp;quot;numpy&amp;quot;, &amp;quot;ndarray&amp;quot;);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; to the module, hope that was correct.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; When I call this function in python, I get:
&lt;br&gt;&amp;gt; AttributeError: 'numpy.ndarray' object has no attribute 'getshape'
&lt;/div&gt;&lt;br&gt;The error comes out because, actually, numpy.ndarray has no getshape method.
&lt;br&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; What is the correct way to do it?
&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;Within your function, declare
&lt;br&gt;&lt;br&gt;const tuple	&amp;shape = extract&amp;lt;tuple&amp;gt;(in.attr(&amp;quot;shape&amp;quot;));
&lt;br&gt;&lt;br&gt;&lt;br&gt;I suggest you to have a look also at my open source library (mds-utils):
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://code.google.com/p/mds-utils/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/mds-utils/&lt;/a&gt;&lt;br&gt;&lt;br&gt;I've written some from/to Python converters that are able to convert a
&lt;br&gt;Python sequence directly into a Boost uBLAS vector or matrix.
&lt;br&gt;If you download the software, you can build the doxygen documentation
&lt;br&gt;(follow the instructions) and you will find an example for each C++
&lt;br&gt;class or function.
&lt;br&gt;&lt;br&gt;In other words, using my library, you could write your function as:
&lt;br&gt;&lt;br&gt;void function(const boost::numeric::ublas::matrix&amp;lt;double&amp;gt;&amp; m) {
&lt;br&gt;...
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;and export it to Python and pass, from Python, a Numpy 2D array.
&lt;br&gt;&lt;br&gt;Have a look at mds-utils and at its usage examples.
&lt;br&gt;&lt;br&gt;Bye,
&lt;br&gt;Michele
&lt;br&gt;&lt;br&gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt; Nathan
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; Cplusplus-sig mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26283549&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Michele De Stefano
&lt;br&gt;&lt;a href=&quot;http://www.linkedin.com/in/micdestefano&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.linkedin.com/in/micdestefano&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;http://code.google.com/p/mds-utils&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://code.google.com/p/mds-utils&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;http://xoomer.virgilio.it/michele_de_stefano&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://xoomer.virgilio.it/michele_de_stefano&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26283549&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/getting-shape-of-numpy-array-tp26283077p26283549.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26283077</id>
	<title>getting shape of numpy array</title>
	<published>2009-11-10T04:45:34Z</published>
	<updated>2009-11-10T04:45:34Z</updated>
	<author>
		<name>Nathan Huesken-14</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I am trying to interaface a numpy array using boost::python::numeric::array.
&lt;br&gt;&lt;br&gt;void function(numeric::array&amp; a)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tuple shape=extract&amp;lt;tuple&amp;gt;(a.getshape());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double x;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i,j;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(i=0;i&amp;lt;shape[0];++i)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(j=0;j&amp;lt;shape[1];++j)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x=extract&amp;lt;double&amp;gt;(a[make_tuple(i,j)]);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;Now I had to add
&lt;br&gt;numeric::array::set_module_and_type(&amp;quot;numpy&amp;quot;, &amp;quot;ndarray&amp;quot;);
&lt;br&gt;&lt;br&gt;to the module, hope that was correct.
&lt;br&gt;&lt;br&gt;When I call this function in python, I get:
&lt;br&gt;AttributeError: 'numpy.ndarray' object has no attribute 'getshape'
&lt;br&gt;&lt;br&gt;What is the correct way to do it?
&lt;br&gt;&lt;br&gt;Thanks!
&lt;br&gt;Nathan 
&lt;br&gt;-- 
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26283077&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/getting-shape-of-numpy-array-tp26283077p26283077.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26259485</id>
	<title>Re: unfriendly python error message (no line number)</title>
	<published>2009-11-08T16:01:49Z</published>
	<updated>2009-11-08T16:01:49Z</updated>
	<author>
		<name>Alex Mohr-2</name>
	</author>
	<content type="html">&lt;div class='shrinkable-quote'&gt;&amp;gt; No, it is not about template-related error messages :-)...
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I am wrapping a class:
&lt;br&gt;&amp;gt; Obviously, the error is that I forgot '()' in the second get(). I 
&lt;br&gt;&amp;gt; am 
&lt;br&gt;&amp;gt; getting this error message:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 0
&lt;br&gt;&amp;gt; &amp;lt;bound method X.get of &amp;lt;Test.X object at 0x2b0db13d4cb0&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there a way to give user a more friendly error message in such 
&lt;br&gt;&amp;gt; case, 
&lt;br&gt;&amp;gt; with at least a line number where it happened?
&lt;/div&gt;&lt;br&gt;This has nothing to do with boost.python. &amp;nbsp;It's how python works. &amp;nbsp;For example:
&lt;br&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; class X(object):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; def __init__(self):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self._x = 0
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; def get(self):
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return self._x
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; x = X()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; print x.get()
&lt;br&gt;0
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; print x.get
&lt;br&gt;&amp;lt;bound method X.get of &amp;lt;__main__.X object at 0x02084FB0&amp;gt;&amp;gt;
&lt;br&gt;&lt;br&gt;And accessing 'x.get' is not in itself an error. &amp;nbsp;You may want to pass that bound method to a function expecting a callable, for instance.
&lt;br&gt;&lt;br&gt;Alex
&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26259485&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/connecting-library-tp26248568p26259485.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26259147</id>
	<title>unfriendly python error message (no line number)</title>
	<published>2009-11-08T15:20:03Z</published>
	<updated>2009-11-08T15:20:03Z</updated>
	<author>
		<name>Thomas Daniel</name>
	</author>
	<content type="html">No, it is not about template-related error messages :-)...
&lt;br&gt;&lt;br&gt;I am wrapping a class:
&lt;br&gt;#include &amp;lt;boost/python.hpp&amp;gt;
&lt;br&gt;&lt;br&gt;struct X {
&lt;br&gt;&amp;nbsp; &amp;nbsp; X() : _x(0) {}
&lt;br&gt;&amp;nbsp; &amp;nbsp; int get() const { return _x; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; int _x;
&lt;br&gt;};
&lt;br&gt;&lt;br&gt;BOOST_PYTHON_MODULE(Test) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; class_&amp;lt;X&amp;gt;(&amp;quot;X&amp;quot;)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .def(&amp;quot;get&amp;quot;, &amp;X::get)
&lt;br&gt;&amp;nbsp; &amp;nbsp; ;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;and testing it with python:
&lt;br&gt;x = X();
&lt;br&gt;print x.get()
&lt;br&gt;print x.get
&lt;br&gt;&lt;br&gt;Obviously, the error is that I forgot '()' in the second get(). I am 
&lt;br&gt;getting this error message:
&lt;br&gt;&lt;br&gt;0
&lt;br&gt;&amp;lt;bound method X.get of &amp;lt;Test.X object at 0x2b0db13d4cb0&amp;gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;Is there a way to give user a more friendly error message in such case, 
&lt;br&gt;with at least a line number where it happened?
&lt;br&gt;&lt;br&gt;Note that if mistype the attribute name, I am getting something I much 
&lt;br&gt;nicer:
&lt;br&gt;&lt;br&gt;Traceback (most recent call last):
&lt;br&gt;&amp;nbsp; File &amp;quot;test.py&amp;quot;, line 5, in &amp;lt;module&amp;gt;
&lt;br&gt;&amp;nbsp; &amp;nbsp; print x.foo
&lt;br&gt;AttributeError: 'X' object has no attribute 'foo'
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26259147&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/connecting-library-tp26248568p26259147.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26250266</id>
	<title>Re: connecting library</title>
	<published>2009-11-07T17:35:06Z</published>
	<updated>2009-11-07T17:35:06Z</updated>
	<author>
		<name>troy d. straszheim</name>
	</author>
	<content type="html">blackmet blackmet wrote:
&lt;br&gt;&amp;gt; Hi, everyone.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Prompt me please, how can I connect extern library to bjam.
&lt;br&gt;&amp;gt; For example:
&lt;br&gt;&amp;gt; connect libd3d9.a from mingw package.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&lt;br&gt;The wrong list I think, asking on you are.
&lt;br&gt;&lt;br&gt;-t
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26250266&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/connecting-library-tp26248568p26250266.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26249301</id>
	<title>Re: Iterators for heterogeneous container</title>
	<published>2009-11-07T14:25:41Z</published>
	<updated>2009-11-07T14:25:41Z</updated>
	<author>
		<name>Thomas Daniel</name>
	</author>
	<content type="html">&lt;br&gt;&lt;br&gt;troy d. straszheim wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Thomas Daniel wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; BOOST_PYTHON_MODULE(vegetables)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;class_&amp;lt;Garden&amp;gt;(&amp;quot;Garden&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_potatoes&amp;quot;, &amp;Garden::get_potatoes)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_tomatoes&amp;quot;, &amp;Garden::get_tomatoes)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;class_&amp;lt;TomatoIter&amp;gt;(&amp;quot;TomatoIter&amp;quot;)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;__iter__&amp;quot;, &amp;TomatoIter::get_next)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp;;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; That at least compiles - unlike all my previous attempts that 
&lt;br&gt;&amp;gt;&amp;gt; generate three pages of template errors - but python complain:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; TypeError: iter() returned non-iterator of type 'Tomato'
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; so now I am trying to figure out how to tell boost that get_tomatoes 
&lt;br&gt;&amp;gt;&amp;gt; returns an iterator ...
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please don't top-post, guys
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; As you know, python iterators have a function next() that returns the 
&lt;br&gt;&amp;gt; next object in the iteree, or throw StopIteration when they're at the 
&lt;br&gt;&amp;gt; end. &amp;nbsp;As you also know, python expects member functions __iter__() to 
&lt;br&gt;&amp;gt; return an iterator. &amp;nbsp;Is the thing returned by TomatoIter::get_next an 
&lt;br&gt;&amp;gt; iterator, ie does it implement the iterator interface?
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -t
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;/div&gt;Thank you very much for the email, you did put me on the right track and 
&lt;br&gt;I finally figured out how to do it, with help from here also: 
&lt;br&gt;&lt;a href=&quot;http://wiki.python.org/moin/boost.python/iterator&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://wiki.python.org/moin/boost.python/iterator&lt;/a&gt;&lt;br&gt;&lt;br&gt;The solution involves creating a wrapper class around get_next(), which 
&lt;br&gt;throws StopIteration when done and a &amp;quot;pass_through&amp;quot; function to bind to 
&lt;br&gt;__iter__:
&lt;br&gt;&lt;br&gt;inline TomatoIter pass_through(const TomatoIter&amp; iter) { return iter; }
&lt;br&gt;&lt;br&gt;Tomato next(TomatoIter&amp; iter) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; Tomato tomato = iter.get_next();
&lt;br&gt;&amp;nbsp; &amp;nbsp; if (!tomato) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; PyErr_SetString(PyExc_StopIteration, &amp;quot;No more data.&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; throw_error_already_set();
&lt;br&gt;&amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; return tomato;
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;Now, I can do this:
&lt;br&gt;BOOST_PYTHON_MODULE(Garden)
&lt;br&gt;{ &amp;nbsp;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;......
&lt;br&gt;&amp;nbsp; &amp;nbsp; class_&amp;lt;TomatoIter&amp;gt;(&amp;quot;TomatoIter&amp;quot;, no_init)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .def(&amp;quot;next&amp;quot;, next)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .def(&amp;quot;__iter__&amp;quot;, pass_through)
&lt;br&gt;&amp;nbsp; &amp;nbsp; ;
&lt;br&gt;&lt;br&gt;and it works.
&lt;br&gt;&lt;br&gt;Thomas
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26249301&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Iterators-for-heterogeneous-container-tp26227744p26249301.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26248568</id>
	<title>connecting library</title>
	<published>2009-11-07T12:38:51Z</published>
	<updated>2009-11-07T12:38:51Z</updated>
	<author>
		<name>blackmet blackmet</name>
	</author>
	<content type="html">&lt;div&gt;Hi, everyone.&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Prompt me please, how can I connect extern library to bjam.&lt;/div&gt;&lt;div&gt;For example:&lt;/div&gt;&lt;div&gt;connect libd3d9.a from mingw package.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Thankful in advance.&lt;/div&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26248568&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/connecting-library-tp26248568p26248568.html" />
</entry>

<entry>
	<id>tag:old.nabble.com,2006:post-26247940</id>
	<title>Re: Iterators for heterogeneous container</title>
	<published>2009-11-07T11:45:22Z</published>
	<updated>2009-11-07T11:45:22Z</updated>
	<author>
		<name>troy d. straszheim</name>
	</author>
	<content type="html">Thomas Daniel wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; BOOST_PYTHON_MODULE(vegetables)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;class_&amp;lt;Garden&amp;gt;(&amp;quot;Garden&amp;quot;)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_potatoes&amp;quot;, &amp;Garden::get_potatoes)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;get_tomatoes&amp;quot;, &amp;Garden::get_tomatoes)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;class_&amp;lt;TomatoIter&amp;gt;(&amp;quot;TomatoIter&amp;quot;)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.def(&amp;quot;__iter__&amp;quot;, &amp;TomatoIter::get_next)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;;
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; That at least compiles - unlike all my previous attempts that generate 
&lt;br&gt;&amp;gt; three pages of template errors - but python complain:
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; TypeError: iter() returned non-iterator of type 'Tomato'
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; so now I am trying to figure out how to tell boost that get_tomatoes 
&lt;br&gt;&amp;gt; returns an iterator ...
&lt;br&gt;&amp;gt; 
&lt;/div&gt;&lt;br&gt;Please don't top-post, guys
&lt;br&gt;&lt;br&gt;As you know, python iterators have a function next() that returns the 
&lt;br&gt;next object in the iteree, or throw StopIteration when they're at the 
&lt;br&gt;end. &amp;nbsp;As you also know, python expects member functions __iter__() to 
&lt;br&gt;return an iterator. &amp;nbsp;Is the thing returned by TomatoIter::get_next an 
&lt;br&gt;iterator, ie does it implement the iterator interface?
&lt;br&gt;&lt;br&gt;-t
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;Cplusplus-sig mailing list
&lt;br&gt;&lt;a href=&quot;http://old.nabble.com/user/SendEmail.jtp?type=post&amp;post=26247940&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;Cplusplus-sig@...&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;http://mail.python.org/mailman/listinfo/cplusplus-sig&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://mail.python.org/mailman/listinfo/cplusplus-sig&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://old.nabble.com/Iterators-for-heterogeneous-container-tp26227744p26247940.html" />
</entry>

</feed>
