[C++-sig] boost/slice.hpp: error in compatibility function get_indicies

2011-12-13 Thread Hans Meine
Hi, I am not sure whether this is already fixed in trunk, but I have just noticed that the compatibility function get_indicies() in line 251 of slice.hpp does not properly pass on the results of calling the renamed function (i.e. it misses the 'return'). In effect, you get a compiler warning t

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Hans Meine
Am Freitag, 2. September 2011, 04:31:24 schrieb Josh Stratton: > BOOST_PYTHON_MODULE(scene) > { > class_("Scene"); > } > > // later calling this > boost::python::register_ptr_to_python< boost::shared_ptr >(); > PyImport_AppendInittab("scene", &initscene); > > So is this all I really need for

Re: [C++-sig] copy constructors and multiple instances

2011-09-02 Thread Hans Meine
Am Donnerstag, 1. September 2011, 22:52:56 schrieb Jim Bosch: > Yup. With boost::shared_ptr, you don't even need to include it as a > template argument of class_, if you instead add the line: > > boost::python::register_ptr_to_python< boost::shared_ptr >(); > > This allows you to return shared_p

Re: [C++-sig] [Boost.Python v3] Features and Scope

2011-08-30 Thread Hans Meine
Am Dienstag, 30. August 2011, 08:42:53 schrieb Jim Bosch: > I don't see how having a global registry makes things any worse from an > ODR perspective. It seems like it's mostly just the same "where do > templates get instantiated" problem that compilers and linkers always > have to deal with. The

Re: [C++-sig] New Major-Release Boost.Python Development

2011-08-29 Thread Hans Meine
Am 26.08.2011 um 20:25 schrieb Jim Bosch: > - … the rvalue converters in particular don't seem to have been intended as part of the public API originally, and I think they're an important part of the library. Correct, great! > - Automatic conversions for newer boost libraries (Fusion, Pointer

Re: [C++-sig] Avoiding implicit boost::python::extract<> conversions

2011-04-07 Thread Hans Meine
Am Donnerstag, 7. April 2011, um 16:02:47 schrieb Murray Cumming: > It looks like boost::python::extract::check() will happily succeed > on an int python object, and boost::python::extract::check() will > likewise succeed on a bool python object. > > Is there an easy way to discover the actual pyt

Re: [C++-sig] Creating a unicode instrance from utf-8 encoded string

2011-02-21 Thread Hans Meine
Am Montag, 21. Februar 2011, um 11:36:52 schrieb Wichert Akkerman: > I'm trying to do something which should be very simple, but I'm not > having much luck figuring out how from the existing documentation. > > For a python 2 project I am trying to return a gettext-translated string > as a unicode

Re: [C++-sig] Derivation from Python str

2010-09-29 Thread Hans Meine
Am Mittwoch 29 September 2010, 17:02:57 schrieb Willi Karel: > I'd like to derive from either Python's built-in 'str' or > boost::python::str, resulting in a class that provides additional > methods / member functions / attributes. [...] AFAIK this is just an unsupported feature of the BPL. I was

Re: [C++-sig] reuse C++ classes that have been wrapped with SWIG

2010-07-20 Thread Hans Meine
Hi Marco! On Tuesday 20 July 2010 09:31:48 Marco Selinger wrote: > Do you have some example, how this can be achieved? Do I need to do some > text processing or parsing of the swig output to find out which (un)wrap > functions to call? I have never worked on the internals of swig, so that I > woul

Re: [C++-sig] Pickle python subclass of C++ interface

2010-07-20 Thread Hans Meine
On Sunday 18 July 2010 11:16:29 John Reid wrote: > I'm not sure what you mean by mix-in, but my first attempt involved > defining pickle suite getstate() and setstate() methods. I did not > define a getinitargs() method. Unfortunately when the derived object was > unpickled, __init__ was called wit

Re: [C++-sig] reuse C++ classes that have been wrapped with SWIG

2010-07-19 Thread Hans Meine
On Thursday 15 July 2010 13:35:55 Marco Selinger wrote: > There is a complete SWIG wrapper for the OpenCV > (http://opencv.willowgarage.com) project. > > I am developing a small image processing application that uses some of the > OpenCV classes. This application will be wrapped using Boost.Python

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

2010-07-07 Thread Hans Meine
On Tuesday 06 July 2010 21:30:25 Anton Yabchinskiy wrote: > On 2010-07-03 05:03:53+0400, Anton Yabchinskiy wrote: > > So, I need PyGILState_Ensure/PyGILState_Release around the > > overridden method call, and PyEval_InitThreads in the module > > initialization. Am I right? Is the following code OK?

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

2010-07-06 Thread Hans Meine
On Saturday 03 July 2010 03:03:53 Anton Yabchinskiy wrote: > So, I need PyGILState_Ensure/PyGILState_Release around the > overridden method call, and PyEval_InitThreads in the module > initialization. Am I right? Is the following code OK? The code looks OK to me at least, but what's your problem?

Re: [C++-sig] Status of Numpy support in boost python

2010-04-21 Thread Hans Meine
Am Montag 08 März 2010 13:32:22 schrieb Pim Schellart: > we are working on a project for which it would be extremely useful if > numpy arrays could be passed as arguments to wrapped C++ methods. > On the website I cannot find any evidence that this is currently > supported by Boost Python. > Is thi

Re: [C++-sig] Boost and wxWidgets

2010-01-14 Thread Hans Meine
Am Donnerstag, 14. Januar 2010 11:41:31 schrieb Joan Carles Jimenez: > On Thu, 2010-01-14 at 08:53 +, Brian O'Kennedy wrote: > > I suspect your problem is unrelated to boost.python. I've never used > > wxWidgets, but a quick google suggests it should be initialised before > > being used. > [...

Re: [C++-sig] [boost.python] How can I wrap operator==?

2010-01-13 Thread Hans Meine
On Mittwoch 13 Januar 2010, Roman Yakovenko wrote: > On Wed, Jan 13, 2010 at 8:57 AM, blp330 wrote: > > class Document > > { > > public: > > > > > > bool operator==(const Document& other) const > > { > > return Compare(other); > > } > [...] > If I understand you right, you need: > > 1. d

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

2010-01-12 Thread Hans Meine
On Dienstag 12 Januar 2010, 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. Oh, OK. > In the doc it tells > you how to make flat function wrappers, but nothing on member function > wrappers. I

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

2010-01-12 Thread Hans Meine
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_OVERLOAD.. I never use BOOST_PYTHON_MEMBER_FUNCTION_OVERLOAD anyway. You may freely

Re: [C++-sig] Avoid Implicitly conversion for non direct conversion

2010-01-06 Thread Hans Meine
Am Mittwoch, 06. Januar 2010 14:10:02 schrieb Renato Araujo: > On Wed, Jan 6, 2010 at 4:59 AM, Hans Meine wrote: > > But only if you pass objects that need to be converted, right? > > Yes but this is the user level I would like to avoid this. Ah, you fear users saying "PyS

Re: [C++-sig] Avoid Implicitly conversion for non direct conversion

2010-01-06 Thread Hans Meine
On Dienstag 05 Januar 2010, Renato Araujo wrote: > I would like to know if is possible to avoid this level of conversion > and tell to boost.python only try the direct conversion, Not as far as I know. > because this > make the functions call slower then normal calls, But only if you pass objec

Re: [C++-sig] Implementation of proper overload resolution

2009-12-21 Thread Hans Meine
Am Freitag, 18. Dezember 2009 16:08:24 schrieb Gustavo Carneiro: > Don't you think that when these overloading problems become an issue it is > a sign of a poorly designed API? I mean, if overloaded functions > parameters are not completely different in type or number, then maybe they > are alread

Re: [C++-sig] what do I need to correctly port boost python extensions

2009-12-21 Thread Hans Meine
Hi Am Montag, 14. Dezember 2009 23:09:31 schrieb Nikolaus Rath: > Alexey Akimov writes: > > However I am still wondering if there is a way to avoid rebuilding the > > extension when one travel from machine to machine. > > The only way is to have exactly the same runtime environment (i.e., > havin

Re: [C++-sig] Help with converters ...

2009-10-19 Thread Hans Meine
Hi Michele! On Montag 19 Oktober 2009, Michele De Stefano wrote: > Now, when I try to implement the "convertible" static member function > of the converter class, I write this (I've extracted only the > interesting part): > > [...] > extract > get_tup0(in[0]), > get

Re: [C++-sig] Trouble optimizing Boost.python integration

2009-09-08 Thread Hans Meine
On Tuesday 25 August 2009 23:48:02 Dan Sanduleac wrote: > The thing is, it proves to be kind of slow compared to Cython/Pyrex code > that does the same. I think it should run faster than Cython code. I think this is because your vectors are too small. I think for such small objects, the implemen

[C++-sig] Using symbols from other python extension modules?

2009-07-30 Thread Hans Meine
Hi, when developing boost::python or SIP-based extension modules, we have repeatedly had the need to use C++ classes or functions from other modules. (E.g. I might have a foocmodule and a corresponding unit test module.) A good use case is a boost::python-like registry (with a slightly differen

Re: [C++-sig] Some thoughts on py3k support

2009-03-19 Thread Hans Meine
On Donnerstag 19 März 2009, Matthew Scouten (TT) wrote: > Ok, Fine. But I want the ability to specify an encoding ONCE and have > use that unless I change it or override a specific conversion. I would want such a thing, too. (Assuming that all 8-bit strings *do* use the same encoding, which will

Re: [C++-sig] Some thoughts on py3k support

2009-03-19 Thread Hans Meine
On Thursday 19 March 2009 09:02:35 Haoyu Bai wrote: > By default we would use PyUnicode_AsUTF8String(), and encoding could > be explicitly specified by a converter policy. That may keep most of > your code compatible. Please do *not* hard-code UTF-8. At least, if you need to guess a default, use

Re: [C++-sig] Some thoughts on py3k support

2009-03-18 Thread Hans Meine
On Tuesday 17 March 2009 21:23:03 Matthew Scouten (TT) wrote: > I can work with whatever you come up with, but it might convenient if a > char* or char[] was treated as a bytes object and a std::string was > treated as a string. Thoughts? I would say one cannot see from the type (i.e. std::string,

Re: [C++-sig] strange behavior with respect to numeric and Boolean overloads

2009-03-17 Thread Hans Meine
On Monday 16 March 2009 22:52:16 Ralf W. Grosse-Kunstleve wrote: > [...] Boost.Python 2 was written when the Python bool type still really > was an int (Python 2.2). [...] On Tuesday 17 March 2009 06:40:14 Roman Yakovenko wrote: > Python code: > > def foo( arg ): > if isinstance( arg, int ): >

Re: [C++-sig] Class scoped enum losing scope

2009-02-05 Thread Hans Meine
On Thursday 05 February 2009 02:58:08 Rao, Sumeeth wrote: > >>> import Boost_FooBar > >>> > >>> bar = Boost_FooBar.Bar() > >>> > >>> var = Boost_FooBar.Foo.eType.TYPE_B < --Seems to understand > that there is a Foo::etype::TYPE_B value > >>> var > > Boost_FooBar.eType.TYPE_B

Re: [C++-sig] Rational for 'Zero-length slice' RuntimeError?

2009-01-05 Thread Hans Meine
On Sonntag 04 Januar 2009, Hans Meine wrote: > I have exported an array-like class using the __getitem__ implementation > given below among its overloads. It uses > boost::python::slice.get_indices(), and I am getting a RuntimeError when I > try to acces e.g. [1:-1] on a 2-element arr

[C++-sig] Rational for 'Zero-length slice' RuntimeError?

2009-01-04 Thread Hans Meine
Hi, I have exported an array-like class using the __getitem__ implementation given below among its overloads. It uses boost::python::slice.get_indices(), and I am getting a RuntimeError when I try to acces e.g. [1:-1] on a 2-element array. What is the rationale for this "Zero-length slice" er

Re: [C++-sig] conversion problem

2008-12-12 Thread Hans Meine
On Thursday 11 December 2008 16:29:34 Luca Sbardella wrote: > The error I get is > *error C2668: 'boost::python::make_tuple' : ambiguous call to overloaded > function > could be 'boost::python::tuple boost::python::make_tuple<_Ty1,_Ty2>(const > A0 &,const A1 &)'** > or 'boost::tuples::tuple >

Re: [C++-sig] Pickle an enum from c++

2008-12-09 Thread Hans Meine
On Monday 08 December 2008 20:02:41 Roman Yakovenko wrote: > 2008/12/8 Matthew Scouten (TT) <[EMAIL PROTECTED]>: > > From the lack of response I assume that no one has any clever ideas to > > make an enum pickleable. Thank you to anyone who put thought into this. > > > :-). > > I thought about wor

Re: [C++-sig] Getting address of wrapped instance?

2008-12-08 Thread Hans Meine
On Monday 08 December 2008 16:23:49 Paul Melis wrote: > On Mon, December 8, 2008 4:12 pm, Stefan Seefeld wrote: > > You may try using > > > > type const &ref = extract(object); > > Hmmm, reading my own post I now see I wasn't completely clear. > > I need this *in Python*. So for a given Python inst

Re: [C++-sig] looking up functions

2008-11-13 Thread Hans Meine
On Thursday 13 November 2008 15:40:31 Alan Baljeu wrote: > I'm reading the Python extension tutorial, and I cannot believe the > embedding section. It tells me the only way to call a python function is > to callout to python to pass back a function object which I then save so I > can call it when

Re: [C++-sig] can these exports be avoided

2008-11-10 Thread Hans Meine
On Monday 10 November 2008 08:56:14 Gennadiy Rozental wrote: > It can be resolved with additional export for class Derived: > > bp::class_,noncopyable>( "Derived", bp::no_init ); > > In which case above print statement starts to show mymodule.Derived. AFAICS that's the proper solution. > But I >

Re: [C++-sig] [pybindgen] references?

2008-11-04 Thread Hans Meine
On Tuesday 04 November 2008 01:18:47 Alan Baljeu wrote: > void baz(foo &x); > > If I have a foo, I call baz with it, foo's contents may change but it's > still the same object. I don't see an issue here, unless foo is a smart > pointer type. Sometimes, baz might store the reference (admittedly, t

Re: [C++-sig] boost::python constructing object from PyObject *

2008-10-29 Thread Hans Meine
On Mittwoch 29 Oktober 2008, David Abrahams wrote: > The above should be a complete guide. Any questions? Great, thanks a lot for the write-up. I think my second question is still left, at least from your post and the docs at http://www.boost.org/doc/libs/1_36_0/libs/python/doc/v2/handle.html I

Re: [C++-sig] boost::python constructing object from PyObject *

2008-10-29 Thread Hans Meine
On Mittwoch 29 Oktober 2008, Dan Eloff wrote: > When creating an object from a PyObject *, how do you distinguish > between a PyObject pointer that is a new reference (must not be > increfed, but must be decrefed) versus a PyObject * that is a borrowed > reference? (should be increfed and decrefed)

Re: [C++-sig] Calling import() multiple times for the same module

2008-10-27 Thread Hans Meine
On Freitag 24 Oktober 2008, Robert Dailey wrote: > What happens if I do the following? > > using namespace boost::python; > > import( "__main__" ).attr( "new_global" ) = 40.0f; > import( "__main__" ).attr( "another_global" ) = 100.0f: > > > My main concern here is performance. I'm wondering if each