Re: [C++-sig] Boost.Python NumPy extension

2016-10-08 Thread Alex Mohr
Cool! Sorry, I don't have the expertise to help with the boost.build aspect, but I did have some questions and comments regarding the feature. Does this add a dependency of boost.python on numpy? We'd love to be able to continue use boost.python without a numpy dependency. We did a nontrivi

Re: [C++-sig] C++ comments to docstrings

2015-11-19 Thread Alex Mohr
Hi Andy, We do something very similar to what you describe, except we use doxygen (www.doxygen.org) to output XML files that we use to generate __doc__ strings for our python bindings. We're primarily a linux shop. I don't know how hard it would be to switch to doxygen, maybe it can deal wi

Re: [C++-sig] virtual functions with default implementation

2015-08-17 Thread Alex Mohr
On 8/17/2015 11:39 AM, Stefan Seefeld wrote: For the case with default implementation, the tutorial gives this wrapper: struct BaseWrap : Base, bpl::wrapper { virtual std::string func() const { if (bpl::override f = this->get_override("func")) return f(); e

Re: [C++-sig] express pointer ownership

2015-08-13 Thread Alex Mohr
On 8/13/2015 4:26 AM, MM wrote: What I want to express is: The t returned by the python function should refer to object T held in c++ memory, and for instance del t should not delete the actual T object in c++ memory Should I still use "return_internal_reference" ? You can use reference_ex

Re: [C++-sig] C++ copy construction and Python object copies

2015-05-29 Thread Alex Mohr
On 5/29/2015 7:28 AM, Stefan Seefeld wrote: Python's copy module allows for objects to be copied. The protocol for this will look up special method __copy__. It seems to me that this would trivially work for C++ objects providing a copy-constructor. However, the copy-constructor isn't automatical

Re: [C++-sig] Weird function call results

2014-12-27 Thread Alex Mohr
On 12/26/14 2:12 AM, ilias wrote: It's not a bug, it's as designed. Boost.python tries function overloads in reverse registration order and picks the first one that works, in the sense that all the arguments convert. Is that behavior specified somewhere in the documentation? I'm not sure it

Re: [C++-sig] Weird function call results

2014-12-20 Thread Alex Mohr
On 12/19/14 5:34 AM, Stefan Seefeld wrote: But if I declare the function f in reversed order: BOOST_PYTHON_MODULE(test) { def("f", f_double); def("f", f_int); } I will see "invoked f(int n = 5)" when I call f(5) and "invoked f(double d = 3.14)" when I call f(3.14) as it has to be. Why doe

Re: [C++-sig] Bugs in the Boost.Python tutorial example

2014-11-17 Thread Alex Mohr
On 11/17/14 4:17 PM, Stefan Seefeld wrote: While the issue looks clear (and the patch good), can you attach a test case that would allow me to reproduce the issue (and observe the fix with the patch applied) ? Minimal test cases always accelerate the processing of reported issues. :-) Also plea

Re: [C++-sig] Bugs in the Boost.Python tutorial example

2014-11-17 Thread Alex Mohr
On 11/17/2014 4:17 PM, Stefan Seefeld wrote: On 17/11/14 06:54 PM, Alex Mohr wrote: On 11/17/2014 2:01 PM, Stefan Seefeld wrote: (Specifically: I'd be happy to help fix issues with the Boost.Python code itself, but I don't feel competent with bjam / Boost.Build, and my knowledge

Re: [C++-sig] Bugs in the Boost.Python tutorial example

2014-11-17 Thread Alex Mohr
On 11/17/2014 2:01 PM, Stefan Seefeld wrote: (Specifically: I'd be happy to help fix issues with the Boost.Python code itself, but I don't feel competent with bjam / Boost.Build, and my knowledge of MSVC is almost non-existent, not to speak of the fact that I have no computer near me running Wind

Re: [C++-sig] Segfault with keyword arguments and overloads.

2013-08-08 Thread Alex Mohr
On 8/8/2013 2:28 AM, Alex Leach wrote: Hi Alex, On Wed, 07 Aug 2013 18:06:24 +0100, Alex Mohr wrote: Thanks for your response. I've responded to your comments in-line below. After further investigation, I believe this can be fixed by simply checking for None when we get 'kv'

Re: [C++-sig] Segfault with keyword arguments and overloads.

2013-08-07 Thread Alex Mohr
Thanks for your response. I've responded to your comments in-line below. After further investigation, I believe this can be fixed by simply checking for None when we get 'kv' from f->m_arg_names while resolving keywords. If we encounter None, that means the overload doesn't accept a keyword

[C++-sig] Segfault with keyword arguments and overloads.

2013-08-06 Thread Alex Mohr
I'm hitting a repeatable segfault trying to upgrade our boost version. I believe there may be a bug with overload resolution in the presence of keyword arguments. Here's a minimal example that crashes for me. // C++ #include static void f1(int a0, int a1) { } static void f2(int a0, int a1, i

Re: [C++-sig] [boost.python] Can't import a wrapped template class

2012-10-26 Thread Alex Mohr
On 10/26/2012 1:27 PM, Stefan Seefeld wrote: The entire issue disappears if you move your member function definitions (including the constructor) from varbls.cpp to varbls.h. Alternatively, explicitly instantiate in varbls.cpp. template class _Variable; Again, you might want to google "explic

Re: [C++-sig] [boost.python] Can't import a wrapped template class

2012-10-26 Thread Alex Mohr
On 10/26/2012 11:16 AM, Paul O. Seidon wrote: would do that. Should I try dont_care = _Variable(); in main.cpp? Looks a bit strange, but would force the compiler to generate code for sure. You either need to inline the ctor in the header or do an explicit instantiation of _Variable somewhere

Re: [C++-sig] Catching Boost.Python.ArgumentError

2010-04-26 Thread Alex Mohr
On 4/26/2010 1:22 AM, Austin Bingham wrote: I feel like I'm missing something simple, but how do I catch Boost.Python.ArgumentException? As far as I can tell, the Boost.Python module is not something I can import explicitly, so I can't write "catch Boost.Python.ArgumentException:". I can do somet

Re: [C++-sig] Boost Python objects and object identity

2009-09-29 Thread Alex Mohr
Renato Araujo wrote: I had the same problem as you in my binding implementation, then I solve the problem using this function: // // a generator with an execute() function which, given a source type // and a pointer to an object of that type, returns its most-derived // /reachable/ type identifi

Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread Alex Mohr
Oh, I assumed that boost::python::object did this already. It does. Think of bp::handle<> as a low-level, bare-bones, smart PyObject*. Think of bp::object as that, *plus* all the fancy c++ API that maps to python API (like obj.attr("foo"), []-operator, ()-operator, etc). I believe bp::obj

Re: [C++-sig] Getting object for PyObject (reference counting)

2009-02-27 Thread Alex Mohr
Murray Cumming wrote: I can't find any definitive documentation that tells me how I should get a boost::python::object to wrap an existing PyObject*. I guess that there's a way to do it that uses an existing reference, and a way that takes an extra reference. You can construct a boost::python::

Re: [C++-sig] Dynamic resolution of members and methods

2008-12-10 Thread Alex Mohr
Override the python special methods __getattr__ or __getattribute__. http://docs.python.org/reference/datamodel.html#attribute-access Alex Jérémie Delaitre wrote: Hello, I have a C++ class that use a custom property system. This property system allows me to add and remove properties at runtim

Re: [C++-sig] profiling C++ python extension

2008-11-21 Thread Alex Mohr
I am aware that oprofile and valgrind exist. Has anyone of you ever done profiling a C or C++ extension with gprof? Not me, but I have to say that valgrind's callgrind tool with kcachegrind to view the results has been perhaps the best profiling experience I've had on Linux. I've had good s

Re: [C++-sig] mutable object has bogus __hash__

2008-11-04 Thread Alex Mohr
I would like to have the __hash__ not exist. These objects are mutable and should NOT be used as keys. Is there a way to hide it? If I have them throw NotImplemented will python do something sensible with that? Python raises a TypeError for unhashable things: >>> [1,2,3].__hash__() Traceback (

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

2008-10-29 Thread Alex Mohr
The best I could find was object(borrowed(ptr)) for new references and object(handle<>(ptr)) for borrowed pointers. I'm not sure if that is accurate, but if so that deserves a nomination for a terrible interface award. The documentation isn't great, but the name 'borrowed' is a hint. Using bor