Re: [C++-sig] C++ chain method works unexpectedly in Python

2011-04-17 Thread Charles Solar
named '__builtin__._'. > So, ``del _`` may help you. > > This behavior is only on interactive shell. When running script, '_' > is not used and Python > may acts you expect. > > > On Mon, Apr 18, 2011 at 9:56 AM, Charles Solar > wrote: > > I

Re: [C++-sig] C++ chain method works unexpectedly in Python

2011-04-17 Thread Charles Solar
8:06 PM, Stefan Seefeld wrote: > On 2011-04-17 20:56, Charles Solar wrote: > >> >> Is there something I should be aware of here? >> > > Just that Python uses garbage collection and you mustn't rely on your > objects being destroyed at a particular point in

[C++-sig] C++ chain method works unexpectedly in Python

2011-04-17 Thread Charles Solar
I have a python module written in C++, and the C++ code has a few instances that involve method chaining. I was experimenting with python support for these methods and I found something odd. However it seems this is more a python eccentricity than Boost Python, consider the following code sample.

Re: [C++-sig] help finding solution to lack of exception handling with boost python on open solaris 64 bit

2010-12-02 Thread Charles Solar
This happens in my application as well, dont know if its a known issue for boost python or not.. I too would like to see a solution; I myself have not had anytime to look into it since exceptions are a rare thing in my app. I can confirm however that a similar problem occurs on Solaris Sparcv9 mach

[C++-sig] Python iterable to std map

2010-11-03 Thread Charles Solar
I have a class interface I expose to python that has methods such as begin, end, rbegin, rend. Its meant to be a class that C++ can iterate over. I now want to make the object defined in python, so python can pass the C++ library an object of python's class and C++ can use it like it would any re

Re: [C++-sig] Using boost.python with Makefile (no bjam)

2010-10-06 Thread Charles Solar
You need to link with libpython as well. libpython should resolve these. On Wed, Oct 6, 2010 at 5:43 AM, Philipp Münzel wrote: > Oh crap, the command that links is of course: > > $ g++ -shared -Wl,-soname,"libhello.so" -L/usr/local/lib -lboost_python > -o libhello.so hello.o > > But I get the un

Re: [C++-sig] How to compile Boost.Python for 32bit on 64bit Linux

2010-10-05 Thread Charles Solar
You need to compile boost python with a 32 bit version of python. The version bjam is finding is 64 bit. If you have a 32 bit python somewhere you need to tell bjam where to find the right headers. See this page http://www.boost.org/doc/libs/1_44_0/libs/python/doc/building.html#configuring-boos

[C++-sig] bp::wrapper class returning reference type

2010-09-22 Thread Charles Solar
I have a bp::wrapper wrapping an interface for use in python. Several functions return reference types of other objects, for example: class IFoo { virtual const IBar& getBar() const = 0; } I found that to get boost python to handle this scenario correctly and eliminate any 'returning address

Re: [C++-sig] How to expose operator[] in boost.python

2010-09-08 Thread Charles Solar
Use the python special function __getitem__ So, something like this: .def( "__getitem__", &Foo::operator[], boost::python::arg( "index" ), boost::python::return_internal_reference<>() ) If you want your container iteratable, see the docs for boost::python::range. Charles On Wed, Sep 8, 2010 at

Re: [C++-sig] boost.python import problem

2010-08-30 Thread Charles Solar
You need to link with boost python as well. g++ boostpy.cc -lpython2.5 -lboost_python -I /usr/include/python2.5 -o boostpy.so -shared should probably do the trick On Mon, Aug 30, 2010 at 12:19 PM, Junwei Zhang wrote: > Hi, everyone, > > I just started study boost.python. and have following pro

[C++-sig] [patch] Make boost python accessible by multiple threads

2010-07-16 Thread Charles Solar
I mentioned it before but I have this patch for boost python that adds code to lock and unlock the gil at all the boundaries I have found between python and boost python. This makes it so multiple threads can call into python without the user having to lock and unlock the gil themselves. I am pre

Re: [C++-sig] X-language polymorphism and multithreading

2010-07-02 Thread Charles Solar
Threads and python do not mix very well. You need to handle locking and unlocking the gil at the boundaries of python and c++. There are several posts here about this problem, just search for thread or 'no current thread' in the archives. A month ago I posted a modified boost python that will hand

Re: [C++-sig] Python exceptions in functions called from C++

2010-06-09 Thread Charles Solar
wrote: > On 06/09/2010 03:11 PM, Charles Solar wrote: > >> I have a boost python library that I build python scripts with. I am not >> embedding python, I think that is worth mentioning right off the bat. >> In my C++ library I have a separate thread calling into python >

[C++-sig] Python exceptions in functions called from C++

2010-06-09 Thread Charles Solar
I have a boost python library that I build python scripts with. I am not embedding python, I think that is worth mentioning right off the bat. In my C++ library I have a separate thread calling into python occasionally and I am finding that if the function I call in python has a python error in it

Re: [C++-sig] Does Boost.Python consider this as "unsupported" (threading related)

2010-06-06 Thread Charles Solar
you can only access python from 1 thread at a time. I have not done any messing around with python types so I do not know if those require the gil but from what you said it seems like they may. In order to work with python from multiple threads you need to manage the gil in your app. Just do a sear

Re: [C++-sig] Does Boost.Python consider this as "unsupported" (threading related)

2010-06-06 Thread Charles Solar
No you can do this, I do the same thing in my project. However, without appropriate GIL locks your new thread cannot call into python. So make sure your new thread of not calling any python callables and you are fine. On Sun, Jun 6, 2010 at 2:30 PM, Embhi Karuche wrote: > Hello > > I have read t

Re: [C++-sig] Boost exception on Solaris AMD64 when importing

2010-06-04 Thread Charles Solar
there. :) On Thu, Jun 3, 2010 at 9:57 AM, Charles Solar wrote: > I am getting a boost exception when I try to import my project linked with > boost python. It occurs in the python _init method so I am pretty sure it > has something to do with boost python. I get this exception: > &

[C++-sig] Boost exception on Solaris AMD64 when importing

2010-06-03 Thread Charles Solar
I am getting a boost exception when I try to import my project linked with boost python. It occurs in the python _init method so I am pretty sure it has something to do with boost python. I get this exception: terminate called after throwing an instance of 'boost::exception_detail::clone_impl'

Re: [C++-sig] Make threading support official

2010-04-15 Thread Charles Solar
I was not originally going to say anything but from what i have skimmed from all these emails seems like someone really needs multithread safety in boost python. Turns out I needed the same thing about 2 months ago, and I looked at TnFOX, changed a few things, patched a couple files, and I am fair

[C++-sig] Virtual methods with arguments and boost::cref

2010-03-06 Thread Charles Solar
I have some virtual methods with default implementations that I am defining according the guidelines on the documentation and I ran into some unexpected behavior. If I define a virtual method in boost python like so void receivedMsg( const sl::Message& msg ) { if( bp::override func_receive

Re: [C++-sig] [Boost.Python] Wrapping C library functions

2010-02-14 Thread Charles Solar
If you want to wrap the library in C I believe you will have to use the standard python API, as boost requires C++ features. It sounds like you do not want to write a wrapper library and instead add code to leptonica to make it python import-able. I would not suggest this approach. If you want to

Re: [C++-sig] Python Exported Method that Takes a Boost::Function Object

2010-02-01 Thread Charles Solar
de though, so no rush on Py++ support, although I bet its as easy as generating a patch or something.. Anyway, great tool, great advice, thanks again. On Mon, Feb 1, 2010 at 1:40 PM, Roman Yakovenko wrote: > On Mon, Feb 1, 2010 at 5:22 PM, Charles Solar > wrote: > > I have a method tha

[C++-sig] Python Exported Method that Takes a Boost::Function Object

2010-02-01 Thread Charles Solar
I have a method that takes a boost function object as so bool createTimer( boost::int64_t interval, boost::function< bool() > function, bool recurring = false ) that I would like to call in python. I tried exporting the class in Py++ but it did not look like it does anything special with that ar

Re: [C++-sig] Member function bp::optional? Or workaround?

2010-01-12 Thread Charles Solar
using and could not find an example of member function default params is here http://www.boost.org/doc/libs/1_41_0/libs/python/doc/tutorial/doc/html/python/functions.html#python.default_arguments perhaps it would be nice to note this very handy bp::object somewhere. Thanks On Tue, Jan 12, 2010 at

Re: [C++-sig] Member function bp::optional? Or workaround?

2010-01-12 Thread Charles Solar
Looks perfect, thanks much. On Tue, Jan 12, 2010 at 2:01 PM, troy d. straszheim wrote: > Charles Solar wrote: > >> Well I want to define the overloads myself anyway, I just do not know how >> to properly setup the small wrapper that will work. In the doc it tells you &

Re: [C++-sig] Member function bp::optional? Or workaround?

2010-01-12 Thread Charles Solar
Meine wrote: > On Dienstag 12 Januar 2010, Charles Solar wrote: > > I have a few default parameters in a couple of my member functions, and > > these functions do not conform to the format required > > forBOOST_PYTHON_MEMBER_FUNCTION_OVERL

[C++-sig] Member function bp::optional? Or workaround?

2010-01-12 Thread Charles Solar
I have a few default parameters in a couple of my member functions, and these functions do not conform to the format required forBOOST_PYTHON_MEMBER_FUNCTION_OVERLOAD.. I was wondering how to go about creating those thin wrappers for these functions. For example, my class would be something like

[C++-sig] PyThreadState_Get: no current thread

2009-12-18 Thread Charles Solar
Its getting kind of late and my eyes are getting tired so I wanted to throw up this problem I am having and see if I can get some feedback on what might be going wrong here. I built boost::python into my app and exported a bunch of stuff. All is well when I just call functions and do not much at