From christoff.kok at ex-mente.co.za Mon Oct 5 18:10:11 2015 From: christoff.kok at ex-mente.co.za (Christoff Kok) Date: Mon, 5 Oct 2015 18:10:11 +0200 Subject: [C++-sig] Boost.Python: Set pointer error. Message-ID: Hi, I am trying to set a raw pointer variable in a wrapped C++ class through python and I receive the following error: Boost.Python.ArgumentError: Python argument types in None.None(A, P) did not match C++ signature: None(AWrapper {lvalue}, P {lvalue}) This is the C++ code: #include #include #include using namespace boost::python; class P { private: int m_amount = 3; public: int GetAmount() { return m_amount; } void SetAmount(int val) { m_amount = val; } }; class A { public: P* GetP() { return m_p;} void SetP(P* val) { m_p = val;} private: P* m_p; }; class Cont { public: P* createP() {auto p = new P(); m_pList.push_back(p); return p;} std::vector& GetPList() { return m_pList; } private: std::vector m_pList; }; struct AWrapper : A, wrapper { void wrapper_SetP(P& p) {this->SetP(&p);} }; BOOST_PYTHON_MODULE(sandbox) { class_("A", init<>()) .add_property("p", make_function(&A::GetP, return_internal_reference<>()), &AWrapper::wrapper_SetP); class_("Cont", init<>()) .def("createP", make_function(&Cont::createP, return_internal_reference<>())) .add_property("pList", make_function(&Cont::GetPList, return_internal_reference<>())); class_("P", init<>()) .add_property("amount", &P::GetAmount, &P::SetAmount); class_>("PList").def(vector_indexing_suite>()); } This is the Python code: import sandbox cont = sandbox.Cont() p1 = cont.createP() print(cont.pList[0].amount) a = sandbox.A() a.p = p1 Any help will be greatly appreciated. I've been struggling with this for a while now. Regards, -- Christoff Kok Software Engineer Ex Mente http://www.ex-mente.co.za christoff.kok at ex-mente.co.za PO Box 10214 Centurion 0046 South Africa tel: +27 12 743 6993 tel: +27 12 654 8198 fax: +27 85 150 1341 -------------- next part -------------- An HTML attachment was scrubbed... URL: From christoff.kok at ex-mente.co.za Fri Oct 9 09:33:18 2015 From: christoff.kok at ex-mente.co.za (Christoff Kok) Date: Fri, 9 Oct 2015 09:33:18 +0200 Subject: [C++-sig] Boost.Python: C++ object in python: Cannot add to C++ base class list. Message-ID: Hi, I am trying to extend existing C++ objects in Python via inheritance. I can do this successfully and run virtual methods overridden in Python. When I however, try to add the python object to a list of pointers of the C++ Base object type(the Base object the python class has overridden), I get a type error: 'Attempting to append an invalid type' I am sure this error is due to there begin no 'implicitly_convertible' functionality from derived* to base*. In C++, this would be defined as so: implicitly_convertible<[Derived_from_base]*,Base*>();. Is it possible to define this in python? How can I achieve this? Here is sample code reproducing this behaviour. *C++* struct Base { virtual ~Base() {} virtual int f() = 0; }; struct A { std::vector& GetBaseList() { return m_base_List; } std::vector m_base_List; }; struct BaseWrap : Base, wrapper { int f() { return this->get_override("f")(); } }; BOOST_PYTHON_MODULE(sandbox) { class_("Base", no_init) .def("f", pure_virtual(&Base::f)); class_("A", init<>()) .add_property("baseList", make_function(&A::GetBaseList, return_internal_reference<>())); //implicitly_convertible<[Derived_from_base]*,Base*>(); class_>("BaseList").def(vector_indexing_suite>()); } *Python* from sandbox import * class derived(Base): def __init__(self): self.name = "test" def f(self): print("Hello Derived!") d = derived() d.f() # Output: Hello Derived! a = A() a.baseList.append(d) # TypeError: Attempting to append an invalid type Any help or ideas will be greatly appreciated. Regards, Christoff -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Thu Oct 15 22:27:29 2015 From: cappy2112 at gmail.com (Tony Cappellini) Date: Thu, 15 Oct 2015 13:27:29 -0700 Subject: [C++-sig] Returning C++ buffer to Python 2.7 Message-ID: I've allocated memory in C++ and need to expose a function to Python so that Python can read this memory as a sequence. I've found this example http://pastebin.com/YGi61R4H from this URL http://stackoverflow.com/questions/16232520/how-to-expose-raw-byte-buffers-with-boostpython which **looks** like it will do what I need, from the description of the code and the request from the original author. However, it looks incomplete to me. There is no code which defines, or explains what *handle<>* is/does, in this line of code object retval = object(handle<>(py_buf)); I would appreciate some help trying to accomplish this (my statement in the first line of this message). Useful (working) examples of Boost-to-Python code are not easily found outside of Stackoverflow. Thanks Tony -------------- next part -------------- An HTML attachment was scrubbed... URL: From wenzel at inf.ethz.ch Sun Oct 18 14:56:42 2015 From: wenzel at inf.ethz.ch (Wenzel Jakob) Date: Sun, 18 Oct 2015 14:56:42 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python Message-ID: Hello all, after being a long-time Boost.Python user, I?ve been working on an alternative that makes more effective use of recent C++11-capable compilers. The overall syntax and ideology are very similar to Boost.Python, but the implementation only requires a few header files with a a vastly smaller amount of code thanks to C++11 lambda functions, tuples and variadic templates. There is also dedicated support for Python?s buffer protocol and NumPy arrays, which is useful for scientific computing applications. So far it?s only used by a few projects, but I think it could be useful to this audience. Code: https://github.com/wjakob/pybind11 Documentation: http://pybind11.readthedocs.org/en/latest/ Best, Wenzel -------------- next part -------------- An HTML attachment was scrubbed... URL: From a.huebl at hzdr.de Mon Oct 19 08:53:31 2015 From: a.huebl at hzdr.de (Axel Huebl) Date: Mon, 19 Oct 2015 09:53:31 +0300 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: <1E5B0771-8A4E-4E1A-9446-8BB9AE064BB4@hzdr.de> Wow the docs and examples look great! Thank you for the tremendous amount of work you put in! I am eager to test this with CUDA7+/C++11 programs. Best, Axel On October 18, 2015 3:56:42 PM EEST, Wenzel Jakob wrote: >Hello all, > >after being a long-time Boost.Python user, I?ve been working on an >alternative that makes more effective use of recent C++11-capable >compilers. The overall syntax and ideology are very similar to >Boost.Python, but the implementation only requires a few header files >with a a vastly smaller amount of code thanks to C++11 lambda >functions, tuples and variadic templates. There is also dedicated >support for Python?s buffer protocol and NumPy arrays, which is useful >for scientific computing applications. > >So far it?s only used by a few projects, but I think it could be useful >to this audience. > >Code: https://github.com/wjakob/pybind11 > >Documentation: http://pybind11.readthedocs.org/en/latest/ > > >Best, >Wenzel > >------------------------------------------------------------------------ > >_______________________________________________ >Cplusplus-sig mailing list >Cplusplus-sig at python.org >https://mail.python.org/mailman/listinfo/cplusplus-sig From trigves at yahoo.com Mon Oct 19 11:14:53 2015 From: trigves at yahoo.com (Trigve Siver) Date: Mon, 19 Oct 2015 09:14:53 +0000 (UTC) Subject: [C++-sig] Returning C++ buffer to Python 2.7 In-Reply-To: References: Message-ID: <786630551.2554043.1445246093343.JavaMail.yahoo@mail.yahoo.com> >________________________________ > From: Tony Cappellini >To: cplusplus-sig at python.org >Sent: Thursday, October 15, 2015 10:27 PM >Subject: [C++-sig] Returning C++ buffer to Python 2.7 > > > > > >I've allocated memory in C++ and need to expose a function to Python >so that Python can read this memory as a sequence. > > > >I've found this example > > >http://pastebin.com/YGi61R4H > > > >from this URL >http://stackoverflow.com/questions/16232520/how-to-expose-raw-byte-buffers-with-boostpython > > > >which **looks** like it will do what I need, from the description of the code and the request from the original author. > > >However, it looks incomplete to me. There is no code which defines, or explains what >handle<> is/does, in this line of code > See http://www.boost.org/doc/libs/1_55_0/libs/python/doc/tutorial/doc/html/python/object.html#python.creating_python_objectfor explanation of handle<> From trigves at yahoo.com Mon Oct 19 11:24:34 2015 From: trigves at yahoo.com (Trigve Siver) Date: Mon, 19 Oct 2015 09:24:34 +0000 (UTC) Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: <606184789.2531486.1445246674530.JavaMail.yahoo@mail.yahoo.com> >________________________________ > From: Wenzel Jakob >To: cplusplus-sig at python.org >Sent: Sunday, October 18, 2015 2:56 PM >Subject: [C++-sig] pybind11 -- alternative to Boost.Python > > > >Hello all, > > >after being a long-time Boost.Python user, I?ve been working on an alternative that makes more effective use of recent C++11-capable compilers. The overall syntax and ideology are very similar to Boost.Python, but the implementation only requires a few header files with a a vastly smaller amount of code thanks to C++11 lambda functions, tuples and variadic templates. There is also dedicated support for Python?s buffer protocol and NumPy arrays, which is useful for scientific computing applications. > > >So far it?s only used by a few projects, but I think it could be useful to this audience. > > >Code: https://github.com/wjakob/pybind11 >Documentation: http://pybind11.readthedocs.org/en/latest/ It looks good. Have you tried contacting the actual boost.python mantainer and maybe propose merge with the boost.python or make a boost.python3 from it? It would be shame not incorporate the useful stuff in boost.python. > >Best, >Wenzel >_______________________________________________ >Cplusplus-sig mailing list >Cplusplus-sig at python.org >https://mail.python.org/mailman/listinfo/cplusplus-sig > > -- Trigve From wenzel at inf.ethz.ch Mon Oct 19 12:24:03 2015 From: wenzel at inf.ethz.ch (Wenzel Jakob) Date: Mon, 19 Oct 2015 12:24:03 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: <606184789.2531486.1445246674530.JavaMail.yahoo@mail.yahoo.com> References: <606184789.2531486.1445246674530.JavaMail.yahoo@mail.yahoo.com> Message-ID: <955558DA-648F-44B8-B480-92C227421ACE@inf.ethz.ch> I would be open to it but have my doubts about the feasibility of a merge. Consider the difference in code size alone: Boost.Python (without dependencies like MPL etc.) uses 26K lines of code, compared to about 2K for pybind11 (3K with all extensions). Apart from that, the libraries take very different internal design decisions, which would likely break existing software that ventures beyond the basic .def() syntax. Cheers, Wenzel > On Oct 19, 2015, at 11:24 AM, Trigve Siver via Cplusplus-sig wrote: > >> ________________________________ >> From: Wenzel Jakob >> To: cplusplus-sig at python.org >> Sent: Sunday, October 18, 2015 2:56 PM >> Subject: [C++-sig] pybind11 -- alternative to Boost.Python >> > It looks good. > Have you tried contacting the actual boost.python mantainer and maybe propose merge with the boost.python or make a boost.python3 from it? It would be shame not incorporate the useful stuff in boost.python. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefan at seefeld.name Mon Oct 19 14:03:19 2015 From: stefan at seefeld.name (Stefan Seefeld) Date: Mon, 19 Oct 2015 08:03:19 -0400 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: <955558DA-648F-44B8-B480-92C227421ACE@inf.ethz.ch> References: <606184789.2531486.1445246674530.JavaMail.yahoo@mail.yahoo.com> <955558DA-648F-44B8-B480-92C227421ACE@inf.ethz.ch> Message-ID: <5624DC07.6010502@seefeld.name> On 19.10.2015 06:24, Wenzel Jakob wrote: > I would be open to it but have my doubts about the feasibility of a > merge. Consider the difference in code size alone: Boost.Python > (without dependencies like MPL etc.) uses 26K lines of code, compared > to about 2K for pybind11 (3K with all extensions). Apart from that, > the libraries take very different internal design decisions, which > would likely break existing software that ventures beyond the basic > .def() syntax. Hi Wenzel, Indeed, I would be very interested in a detailed comparison. Modernizing Boost.Python by using C++11 features (for example) and stripping out obsolete compiler support is one way to move forward. That in itself will help a lot, and may even allow Boost.Python to strip off dependencies to other Boost libraries. I'd be curious to learn about those design decisions that you are alluding to that lead to incompatibilities. Such a document may ultimately also be important for potential users when they consider the alternatives. Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin... From talljimbo at gmail.com Mon Oct 19 14:15:34 2015 From: talljimbo at gmail.com (Jim Bosch) Date: Mon, 19 Oct 2015 21:15:34 +0900 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: At first glance, this looks great. I've been tinkering with something like this for a while now, but it's never amounted to anything more than a C++11 learning project, and this looks quite solid in comparison. It may be a long time before I get a chance to evaluate pybind11 for use in my own projects, but as a prelude to that I was wondering if you could say anything about support for custom converters and cross-module type conversion, which I didn't see mentioned in the docs (though I just skimmed them). Are you using the same sort of global registry Boost.Python used? If so, I'm curious how that works with a header-only library. Jim On Sun, Oct 18, 2015 at 9:56 PM, Wenzel Jakob wrote: > Hello all, > > after being a long-time Boost.Python user, I?ve been working on an > alternative that makes more effective use of recent C++11-capable > compilers. The overall syntax and ideology are very similar to > Boost.Python, but the implementation only requires a few header files with > a a vastly smaller amount of code thanks to C++11 lambda functions, tuples > and variadic templates. There is also dedicated support for Python?s buffer > protocol and NumPy arrays, which is useful for scientific computing > applications. > > So far it?s only used by a few projects, but I think it could be useful to > this audience. > > Code: https://github.com/wjakob/pybind11 > Documentation: http://pybind11.readthedocs.org/en/latest/ > > Best, > Wenzel > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wenzel at inf.ethz.ch Mon Oct 19 18:10:42 2015 From: wenzel at inf.ethz.ch (Wenzel Jakob) Date: Mon, 19 Oct 2015 18:10:42 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: <3E80B87A-CDC7-49C6-AABC-C03B36261F6B@inf.ethz.ch> Hi, it would take a long time to discuss all differences, but I can give some examples. There are basically three ways of interfacing with Python objects in pybind11. 1. using wrapper classes like pybind11::object (analogous to boost::python::object) 2. by creating bindings that map a C++ type to Python ? this is done using pybind11::class_ (analogous to boost::python::class_) 3. by declaring a partial template overload that does transparent conversions between different types. Boost.Python?s approach for communicating type information (item 2. in the above list) between modules entails linking against a shared library with a few containers storing the relevant data. In comparison, pybind11 installs a __pybind11__ capsule object in the global scope for this purpose, which avoids the library dependency. Any extra binding library that is loaded just registers its types there. In terms of the underlying implementation, 1. and 2. are pretty basic, and 3. is where a lot of the interesting things happen. This is basically a big list of partial template overloads of a class named type_caster which try to match various common types recursively. I?ll show just one example of how C++11 can considerably simplify implementation details here. For instance, consider the converter which enables transparent conversions between std::tuple and Python?s ?tuple? class. Among other things, pybind11 uses this to convert function arguments to Python objects. The top-level signature matches an arbitrary tuple (that could even be nested, or other kinds of type concoctions ? :)) I?ll expand the snippet literal programming-style, adding code to the part. template class type_caster> { typedef std::tuple type; enum { size = sizeof...(Tuple) }; }; The first thing we?ll do is to declare sub-converters to deal with the individual tuple element types. The decay template simplifies the base type as much as possible by stripping type modifiers like pointers, references, const, etc. (those are handled separately) += std::tuple::type>...> value; The following function takes a tuple from Python and converts it into the corresponding C++ object, returning false if the conversion wasn?t possible. It expects a special type index_sequence<0,1,2,3,?., N-1> as an argument, where N is the length of the tuple. This is a pretty common workaround to enable something resembling a loop over variadic template arguments rather than writing a messy recursive function. += protected: template bool load(PyObject *src, index_sequence) { if (!PyTuple_Check(src)) return false; if (PyTuple_Size(src) != size) return false; std::array results {{ (PyTuple_GET_ITEM(src, Indices) != nullptr ? std::get(value).load(PyTuple_GET_ITEM(src, Indices)) : false)... }}; for (bool r : results) if (!r) return false; return true; } The following function function calls the above protected function with the needed index_sequence += public: bool load(PyObject *src) { return load(src, typename make_index_sequence::type()); } which is constructed using a much shorter recursive implementation that runs at compile time: template struct index_sequence { }; template struct make_index_sequence : make_index_sequence { }; template struct make_index_sequence <0, S...> { typedef index_sequence type; }; Here is another very short example that I like: this converts a Python function into a std::function<> using a stateful lambda closure that invokes the function object?s call() function. With this partial template overload, we can easily call functions that take std::function<>s as argument using Python functions. Something similar is also possible for the reverse direction. template struct type_caster> { typedef std::function type; public: bool load(PyObject *src_) { if (!PyFunction_Check(src_)) return false; object src(src_, true); value = [src](Args... args) -> Return { object retval(handle(src).call(std::move(args)...)); return retval.template cast(); }; return true; } protected: type value; }. The codebase contains many other examples. For instance, the optional auto-vectorization support over NumPy array arguments is something that would have been very painful to do with C++03. Best, Wenzel > On Oct 19, 2015, at 2:15 PM, Jim Bosch wrote: > > At first glance, this looks great. I've been tinkering with something like this for a while now, but it's never amounted to anything more than a C++11 learning project, and this looks quite solid in comparison. > > It may be a long time before I get a chance to evaluate pybind11 for use in my own projects, but as a prelude to that I was wondering if you could say anything about support for custom converters and cross-module type conversion, which I didn't see mentioned in the docs (though I just skimmed them). Are you using the same sort of global registry Boost.Python used? If so, I'm curious how that works with a header-only library. > > Jim > > > > > On Sun, Oct 18, 2015 at 9:56 PM, Wenzel Jakob > wrote: > Hello all, > > after being a long-time Boost.Python user, I?ve been working on an alternative that makes more effective use of recent C++11-capable compilers. The overall syntax and ideology are very similar to Boost.Python, but the implementation only requires a few header files with a a vastly smaller amount of code thanks to C++11 lambda functions, tuples and variadic templates. There is also dedicated support for Python?s buffer protocol and NumPy arrays, which is useful for scientific computing applications. > > So far it?s only used by a few projects, but I think it could be useful to this audience. > > Code: https://github.com/wjakob/pybind11 > Documentation: http://pybind11.readthedocs.org/en/latest/ > > Best, > Wenzel > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From cappy2112 at gmail.com Mon Oct 19 19:11:54 2015 From: cappy2112 at gmail.com (Tony Cappellini) Date: Mon, 19 Oct 2015 10:11:54 -0700 Subject: [C++-sig] Returning C++ buffer to Python 2.7 In-Reply-To: <786630551.2554043.1445246093343.JavaMail.yahoo@mail.yahoo.com> References: <786630551.2554043.1445246093343.JavaMail.yahoo@mail.yahoo.com> Message-ID: > > See > > http://www.boost.org/doc/libs/1_55_0/libs/python/doc/tutorial/doc/html/python/object.html#python.creating_python_objectfor > explanation of handle<> > Thank You! -------------- next part -------------- An HTML attachment was scrubbed... URL: From bluescarni at gmail.com Mon Oct 19 21:58:05 2015 From: bluescarni at gmail.com (Francesco Biscani) Date: Mon, 19 Oct 2015 21:58:05 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: This looks really neat! Do you have any measure on the memory/cpu performance wrt Boost.Python when compiling large bindings? I would expect that variadic templates and all the other C++11 goodies are more efficient than the preprocessor magic used in Boost Python, from this point of view. Cheers, Francesco. On 18 October 2015 at 14:56, Wenzel Jakob wrote: > Hello all, > > after being a long-time Boost.Python user, I?ve been working on an > alternative that makes more effective use of recent C++11-capable > compilers. The overall syntax and ideology are very similar to > Boost.Python, but the implementation only requires a few header files with > a a vastly smaller amount of code thanks to C++11 lambda functions, tuples > and variadic templates. There is also dedicated support for Python?s buffer > protocol and NumPy arrays, which is useful for scientific computing > applications. > > So far it?s only used by a few projects, but I think it could be useful to > this audience. > > Code: https://github.com/wjakob/pybind11 > Documentation: http://pybind11.readthedocs.org/en/latest/ > > Best, > Wenzel > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eu at doxos.eu Mon Oct 19 22:31:18 2015 From: eu at doxos.eu (=?UTF-8?B?VsOhY2xhdiDFoG1pbGF1ZXI=?=) Date: Mon, 19 Oct 2015 22:31:18 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: <56255316.2060109@doxos.eu> > Code: https://github.com/wjakob/pybind11 > Documentation: http://pybind11.readthedocs.org/en/latest/ Hi Wenzel, it looks excelent. There are a few points in boost::python which have been unresolved for a long time: straightforward support for aligned types (Eigen comes to mind) and some subtle bugs in shared_ptr/weak_ptr (e.g. not holding GIL when deleting some python objects and crashing) which are not being fixed upstream. Could you comment on those? I would suggest that the documents include some migration hints from boost::python, if I if ever attempt it (something like: use reference_internal instead of with_custodian_and_ward, this is how you write an equivalent of raw_function/raw_constructor). Cheers, V?clav -------------- next part -------------- An HTML attachment was scrubbed... URL: From wenzel at inf.ethz.ch Tue Oct 20 01:13:23 2015 From: wenzel at inf.ethz.ch (Wenzel Jakob) Date: Tue, 20 Oct 2015 01:13:23 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: Message-ID: <17EB9E12-C978-417A-982C-91546A517968@inf.ethz.ch> Hi, I became curious about this myself and ran a simple benchmark for automatically generated binding code of increasing size. The compilation times for Boost.Python and pybind11 turn out to be fairly similar. However, there is a significant difference in terms of the size of the compilation result, which is almost twice as large for Boost.Python. See the details here: http://pybind11.readthedocs.org/en/latest/benchmark.html Best, Wenzel > On Oct 19, 2015, at 9:58 PM, Francesco Biscani wrote: > > This looks really neat! > > Do you have any measure on the memory/cpu performance wrt Boost.Python when compiling large bindings? I would expect that variadic templates and all the other C++11 goodies are more efficient than the preprocessor magic used in Boost Python, from this point of view. > > Cheers, > > Francesco. > > On 18 October 2015 at 14:56, Wenzel Jakob > wrote: > Hello all, > > after being a long-time Boost.Python user, I?ve been working on an alternative that makes more effective use of recent C++11-capable compilers. The overall syntax and ideology are very similar to Boost.Python, but the implementation only requires a few header files with a a vastly smaller amount of code thanks to C++11 lambda functions, tuples and variadic templates. There is also dedicated support for Python?s buffer protocol and NumPy arrays, which is useful for scientific computing applications. > > So far it?s only used by a few projects, but I think it could be useful to this audience. > > Code: https://github.com/wjakob/pybind11 > Documentation: http://pybind11.readthedocs.org/en/latest/ > > Best, > Wenzel > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From ndbecker2 at gmail.com Tue Oct 20 13:33:15 2015 From: ndbecker2 at gmail.com (Neal Becker) Date: Tue, 20 Oct 2015 07:33:15 -0400 Subject: [C++-sig] pybind11 -- alternative to Boost.Python References: <17EB9E12-C978-417A-982C-91546A517968@inf.ethz.ch> Message-ID: I noticed you used -flto when building the shared libs. Do you find this makes a difference? From wenzel at inf.ethz.ch Tue Oct 20 14:02:23 2015 From: wenzel at inf.ethz.ch (Wenzel Jakob) Date: Tue, 20 Oct 2015 14:02:23 +0200 Subject: [C++-sig] pybind11 -- alternative to Boost.Python In-Reply-To: References: <17EB9E12-C978-417A-982C-91546A517968@inf.ethz.ch> Message-ID: I use that by default for compiling Python bindings. It should not make any difference for just a single file (including this testcase), but I found that it yields consistently smaller shared libraries when dealing with lots of compilation units. Wenzel > On Oct 20, 2015, at 1:33 PM, Neal Becker wrote: > > I noticed you used -flto when building the shared libs. Do you find this > makes a difference? > > _______________________________________________ > Cplusplus-sig mailing list > Cplusplus-sig at python.org > https://mail.python.org/mailman/listinfo/cplusplus-sig From gb.gabrielebrambilla at gmail.com Wed Oct 21 18:41:13 2015 From: gb.gabrielebrambilla at gmail.com (Gabriele Brambilla) Date: Wed, 21 Oct 2015 18:41:13 +0200 Subject: [C++-sig] PyUblas: PROBLEMS WITH PythonBoost libraries Message-ID: Hi all, I tried to install PyUblas via pip install but I received an error about the Boost python libraries. I have a Mac and I am using Anaconda for Python I tried manually doing: 1 11:31 setenv CPPFLAGS "-I/opt/local/include" 2 11:31 setenv LDFLAGS "-L/opt/local/lib" 3 11:31 cd /tmp 4 11:31 tar zxf ~/Downloads/PyUblas-2013.1.tar.gz 5 11:31 cd PyUblas-2013.1/ 6 11:32 ./configure.py 7 11:32 vi siteconf.py The siteconf.py edit was changing BOOST_PYTHON_LIBNAME = ['boost_python'] to BOOST_PYTHON_LIBNAME = ['boost_python-mt'] 8 11:32 python setup.py install the install complete, but when I try to import pyublas I got this error: but "import pyublas" fails with: [gs66-stumbras:~] gbrambil% python Python 2.7.6 (default, Dec 12 2014, 14:02:59) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pyublas Traceback (most recent call last): File "", line 1, in File "/Users/gbrambil/anaconda/lib/python2.7/site-packages/PyUblas-2013.1-py2.7-macosx-10.5-x86_64.egg/pyublas/__init__.py", line 2, in import pyublas._internal ImportError: dlopen(/Users/gbrambil/anaconda/lib/python2.7/site-packages/PyUblas-2013.1-py2.7-macosx-10.5-x86_64.egg/pyublas/_internal.so, 2): Symbol not found: __ZNSoD0Ev Referenced from: /Users/gbrambil/anaconda/lib/python2.7/site-packages/PyUblas-2013.1-py2.7-macosx-10.5-x86_64.egg/pyublas/_internal.so Expected in: dynamic lookup >>> Confirming missing symbol: [gs66-stumbras:~] gbrambil% nm /Users/gbrambil/anaconda/lib/python2.7/site-packages/PyUblas-2013.1-py2.7-macosx-10.5-x86_64.egg/pyublas/_internal.so | grep __ZNSoD0Ev U __ZNSoD0Ev Do you know what the problem is? Thanks Gabriele -------------- next part -------------- An HTML attachment was scrubbed... URL: