Re: [C++-sig] Arrays to python

2010-01-20 Thread Jim Bosch
ogle.com/p/ndarray/ Documentation for the Python stuff isn't great, but I'd be happy to answer any questions. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Arrays to python

2010-01-21 Thread Jim Bosch
On Thu, 2010-01-21 at 09:10 -0500, Ng, Enrico wrote: > I had hoped that there was something simple after seeing the numeric part in > the documentation. Well, if you're content with a 1-D array and speed isn't a big issue, you can just copy the elements of your array into a Python list like this:

Re: [C++-sig] [Boost Python] Extended class loosing attributes when saving as pointer to BaseClass in C++

2010-01-22 Thread Jim Bosch
and you can get me a complete example that demonstrates the problem, I'll see about making a patch to make that happen. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] copy boost::python::object crashes

2010-01-23 Thread Jim Bosch
ed that. It's probably a good idea to avoid global variables in source files anyhow. Wrapping it in a function: object & getY() { static object y; return y; } void setY(object y1) { getY() = y1; } might eliminate your segfault. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] copy boost::python::object crashes

2010-01-24 Thread Jim Bosch
On Sun, 2010-01-24 at 09:30 +, sergun wrote: > I have changed setY function to: > void setY(PyObject * y1) { y = object(handle<>(y1)); } > > and it doesn’t make crash now. > I’m not sure that such code has no problems and very interested to know why > assignment of one bp::object to another

Re: [C++-sig] Please help: boost python 1.41 extension problem

2010-01-25 Thread Jim Bosch
might learn something by reporting your error message either to the gcc developers (or Red Hat, since they're more directly responsible for the binary you have). At the very least, I imagine they'd like to hear about it. Jim Bosch ___ Cplusplus-

Re: [C++-sig] Please help: boost python 1.41 extension problem

2010-01-25 Thread Jim Bosch
and reflects whether a compiler supports in-class initialization of static integral constant members. Perhaps your compiler does not fully support this feature, but boost thinks it does? Try adding the line #define BOOST_NO_INCLASS_MEMBER_INITIALIZ

Re: [C++-sig] Problem running the quickstart

2010-01-26 Thread Jim Bosch
. Did I miss > something? > Thanks in advance! > That file is in boost/libs/python/quickstart/. I don't know much about running Python in Windows, but it looks like it was just looking in the default system Python locations. You may have to update your PYTHONPATH. Jim Bosch _

Re: [C++-sig] wrapping vector of pointers

2010-01-26 Thread Jim Bosch
and cannot be relied upon // to be valid after the function exits. } You can then wrap "py_accept_vector" in the usual way: boost::python::def("accept_vector", py_accept_vector); Hope that helps! Jim Bosch _

Re: [C++-sig] Problem running the quickstart

2010-01-27 Thread Jim Bosch
On Wed, 2010-01-27 at 11:37 +0100, Daniel Lidström wrote: > Neither the example nor the quickstart folders contain test_extending.py: ... > > Am I looking in the wrong place? > Nope, that's right. It should be libs/python/examples/quickstart (I forgot the "examples" earlier). I don't know why

Re: [C++-sig] Checking for or null PyObject* or PyNone

2010-02-07 Thread Jim Bosch
And what's the correct way to check for PyNone other than > if (obj == boost::python::object()) > ? > I think that's the standard way. I suppose if (obj.ptr() == Py_None) might be faster on some compilers, but it's almost certainly not worth worrying about. Jim Bosc

Re: [C++-sig] Boost Python: C++ struct with a function pointer

2010-03-02 Thread Jim Bosch
bject foo_get_func1(foo & self) { return bp::make_function(self.func1); } bp::class_("foo") .add_property("func1", foo_get_func1) ; I haven't tested that snippet, so it may need some tweaks. But hopefully it will get you started. Jim Bosch _

Re: [C++-sig] Boost Python: C++ struct with a function pointer

2010-03-02 Thread Jim Bosch
On Wed, 2010-03-03 at 07:48 +0530, puneet goel wrote: > Mathew/Jim > > > If you just need your Python interface to support calling those function > > pointers, not adding new functions in Python, it's relatively easy. > > Thanks for your support. > > Actually I need to pass data from Python to C

Re: [C++-sig] dict.has_key works in a Python script, not in C++

2010-03-03 Thread Jim Bosch
identity checks (such as address comparison) instead > of a deep equal test, as a faster way to look up objects. > That's exactly what it does, unless your object implements the __hash__ special method. Do that (and in so doing, promise that the return value of __hash__ will never

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

2010-03-08 Thread Jim Bosch
that I should be aware of? What I would consider a compute Numpy interface is probably not something that should be added into the main boost.python library itself (and I think it would need it's own shared library if done properly). Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

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

2010-03-08 Thread Jim Bosch
On Mon, 2010-03-08 at 13:40 -0500, Stefan Seefeld wrote: > On 03/08/2010 01:30 PM, Neal Becker wrote: > > > > Check out pyublas > > > > Thanks for mentioning that. > > Yes, this looks very useful. In fact, my PyArray wrapper was inspired by > pyublas. Definitely useful, and from what I've s

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

2010-03-08 Thread Jim Bosch
On Mon, 2010-03-08 at 14:38 -0500, Stefan Seefeld wrote: > To me, the most important feature in adding proper PyArray support to > boost.python is the ability to access the much richer API, such as > direct-data access via PyArr_DATA, PyArr_GETPTRX, etc., which allow me > to build my own adapte

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

2010-03-09 Thread Jim Bosch
On Tue, 2010-03-09 at 11:53 -0500, Neal Becker wrote: > No luck with boost-1.42. fedora-12 boost-1.39 seems OK. > > Lots of errors, like: > /usr/local/src/boost.hg/boost/fusion/container/vector/convert.hpp: In > instantiation of > 'boost::fusion::result_of::as_vector, > > 0>, boost::fusion::v

Re: [C++-sig] boost.python class constructor error

2010-03-11 Thread Jim Bosch
On Fri, 2010-03-12 at 10:36 +0800, hitesh dhiman wrote: > This error occurs when i declare the class constructor in the c++ > header file and the definition in the .cpp file. Bjam throws up a > LNK2019 error, unresolved symbol. > But if i declare the class constructor in the header file itself, the

Re: [C++-sig] boost.python class constructor error

2010-03-11 Thread Jim Bosch
On Fri, 2010-03-12 at 12:01 +0800, hitesh dhiman wrote: > hi Jim > Will it help if i post my jam-root file? Its included below: > import python ; > > > if ! [ python.configured ] > { > ECHO "notice: no Python configured in user-config.jam" ; > ECHO "notice: will use default configuration"

Re: [C++-sig] Ownership of a C++ object extended in Python using wrapper

2010-03-16 Thread Jim Bosch
Or did you > identify some use cases which favor a method rather the other one? > I generally use shared_ptr storage for everything, but I often mix that with with_custodian_and_ward and its cousins (return_internal_reference, in particular) when I don't have access to a shared_ptr on the C++ side. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] errors while setting arguments description for the method

2010-03-17 Thread Jim Bosch
nt), but you do have to supply the call policies argument manually if you want to supply keywords - make_constructor just doesn't have the overloads that make_function does. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Having problems with returned object.

2010-03-17 Thread Jim Bosch
> ...extracting get() from script... > MyClass m ( getObj() ); > --- > I don't really understand what you're doing here. Where is getObj() defined, and wh

Re: [C++-sig] Fwd: passing pointers from python

2010-03-18 Thread Jim Bosch
Python. Note that you can wrap a free function that takes a World& as its first argument as a member function of the World class; there will be no difference between that and wrapping a true member function on the Python side. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] vc++ assertion error upon runtime

2010-03-18 Thread Jim Bosch
On Fri, 2010-03-19 at 14:45 +0800, hitesh dhiman wrote: > Hi all, > I'm trying to gain access to functions that use pointers as > arguments. I have written the wrapper file that converts the arguments > into pointers. The compilation works successfully, but when i try to > run the code from python

Re: [C++-sig] boost.pyton scope bug?

2010-03-19 Thread Jim Bosch
ge the __module__ attribute; I often import my wrapped names into different submodules in a package and adjust their __module__ accordingly to make a Python interface that mirrors the C++ namespaces better - but all that has to be done in Python; boost python can't do it for you (maybe Py++ could

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread Jim Bosch
_ If you've wrapped all classes with shared_ptr storage, to-python converts should always produce the most-derived type in Python, and I think that's what you want on the Python side. This may not work if you can't use shared_ptr storage for some reason, or if you ret

Re: [C++-sig] [Py++] boost::shared_ptr casting

2010-03-20 Thread Jim Bosch
On Sun, 2010-03-21 at 03:07 +0100, peoro wrote: > Yes, having all of the objects at their most-derived type would be > what I need, but it's not what happens. > > I posted a piece of C++ code that shows what I do (I exported it using > py++ without any further modification): all of the pointers my

Re: [C++-sig] vc++ assertion error upon runtime

2010-03-21 Thread Jim Bosch
On Fri, 2010-03-19 at 14:45 +0800, hitesh dhiman wrote: > > Hi all, > > I'm trying to gain access to functions that use pointers as > > arguments. I have written the wrapper file that converts the > arguments > > into pointers. The compilation works successf

Re: [C++-sig] Conversion of python files to C++ ostreams

2010-03-29 Thread Jim Bosch
ncUseCount() when I construct the FileStarOstream, when would > I call the corresponding PyFile_DecUseCount()? GIL is the global interpreter lock. You only need to worry about it if your program is multithreaded on the C++ side. In this case, if you make the FileStarOstream an object manager

[C++-sig] single-declaration code generation in Py++

2010-05-09 Thread Jim Bosch
ps or suggestions on where to get started. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] Miscellaneous Boost.Python Utilities

2010-05-13 Thread Jim Bosch
ngs that don't depend on non-Boost libraries, however. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Problem with overloading between int and double

2010-05-19 Thread Jim Bosch
t;get_type",&Test::get_type) .staticmethod("create") ; } I admit it's not a very satisfying solution. Maybe someone else has a better idea, but I think fixing this in Boost.Python would require a lot of work. Jim Bosch __

Re: [C++-sig] automatic conversion of tuple to vector

2010-05-24 Thread Jim Bosch
re you have to make copies. HTH Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] No to_python (by-value) converter found for C++ type

2010-05-24 Thread Jim Bosch
nerator you're using (Py++?) uses to determine whether to thrown noncopyable in, there, but I suspect it would do so if you don't have a public copy constructor defined available, even if you didn't use boost::noncopyable to get rid of it. May

Re: [C++-sig] automatic conversion of tuple to vector

2010-05-25 Thread Jim Bosch
he call? I've been stumped by this problem in boost python before, and I had previously come the conclusion that it was impossible, so I'd be very interested to hear it if you have a solution. Jim Bosch ___ Cplusplus-sig mailing list

Re: [C++-sig] Boost.Python Problem

2010-05-25 Thread Jim Bosch
using namespace boost::python; BOOST_PYTHON_MODULE(example) { object main_module((handle<>(borrowed(PyImport_AddModule("__main__"); object main_namespace = main_module.attr("__dict__"); } ...compiles and imports just fine. Jim Bosch ___

Re: [C++-sig] Fill a python::str with contents of a vector ?

2010-06-06 Thread Jim Bosch
hon C API to avoid the temporary: python::str data( python::handle<>( PyString_FromStringAndSize(&myvector.front(), myvector.size()) ) ); Note that this will not fail gracefully if myvector.empty(). Jim Bosch ___ Cplusplus-s

Re: [C++-sig] Exposing std::list<> via Boost.Python

2010-06-22 Thread Jim Bosch
on't need random access to make a python iterable at all - Python's built-in dict and set types are examples. All you need to do is define an __iter__ special function, and you should be able to do that fairly automatically using the stuff described here: http://www.boost.org

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

2010-07-16 Thread Jim Bosch
d? Does it just add too much overhead for those who don't need it? (bump) Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

[C++-sig] dynamic linking in Linux

2010-07-23 Thread Jim Bosch
r similar option, using sys.setdlopenflags, seems to be less favored because the dl module needed to get the flags has been deprecated in Python itself. Is this just the current state of things? Are there any efforts underway to improve matters? Or was I on track in the firs

Re: [C++-sig] dynamic linking in Linux

2010-07-23 Thread Jim Bosch
On 07/23/2010 12:08 AM, Jim Bosch wrote: I've just run into the "wontfix" problem detailed here: https://svn.boost.org/trac/boost/ticket/3210 Essentially, shared information held in one module (such as RTTI stuff needed for dynamic cast) isn't available to another module,

Re: [C++-sig] How to derive from an abstract base class

2010-07-23 Thread Jim Bosch
ot;Derived") .def("f",&Derived::f); def("func", func, "Calls the method f of its argument"); } (just swap the order of the class_ statements) Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Calling a C++ function with arguments by reference (lvalues)

2010-08-02 Thread Jim Bosch
ble, and you can give it the necessary operators to interact properly with regular ints. And you'll be able to pass it by-value to functions. But my guess is that it's probably much easier just to pass a dictionary to all of your functions. Hope that helps! Jim Bosch

Re: [C++-sig] Python __init__ that copies internal reference, boost.python

2010-08-16 Thread Jim Bosch
ython::extract< boost::shared_ptr >(arg); } BOOST_PYTHON_MODULE(example) { boost::python::class_("MyClass") .def("__init__", boost::python::make_constructor(&construct)) ; boost::python::register_ptr_to_python< boost::shared_ptr >(); }

Re: [C++-sig] Python __init__ that copies internal reference, boost.python

2010-08-16 Thread Jim Bosch
On 08/16/2010 04:21 PM, Branan Purvine-Riley wrote: That's definitely on the right track. Not quite right because of some of the oddities of what I'm working with here. It's a game engine, and none of the pointers are stored in a smart pointer container of any kind. Unfortunately make_constructo

Re: [C++-sig] converting a PyObject into its C-Type

2010-08-27 Thread Jim Bosch
;t contain the appropriate C++ type. By the way, Boost.Python can also wrap functions taking bp::object arguments, and that might be cleaner than a raw PyObject *. HTH! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Strange boost::python::object behaviour

2010-08-27 Thread Jim Bosch
the problem? I don't have any ideas on what's going wrong based on what you've posted so far. Thanks! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

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

2010-08-30 Thread Jim Bosch
append a suffix to get the appropriate boost_python shared library in some cases. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Some questions when making a C++ project as python externsions

2010-09-07 Thread Jim Bosch
on is done with it. When you return by value or smart pointer, there's generally no need to use call policies, and Boost.Python is prettying good at throwing up a compile error when you need to use them. Hope that helps! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Question about using IT++ in boost.python

2010-09-07 Thread Jim Bosch
namespace vec b= linspace(0,2*n,10);// std::cout<", line 1, in ImportError: ./hello.so: undefined symbol: _ZN4itpp8linspaceEddi any suggestion is appreciate!! It looks like you need to link your Python module (it's a shared library) against the IT++ shared library

Re: [C++-sig] operator in return false while operator == return true

2010-09-24 Thread Jim Bosch
On 09/24/2010 02:42 PM, Simon W wrote: Hey, sorry for the lacking information. May I declare it as this instead: C++ Class class GameObjectManager { map a_map; // this map has "nothing" to do with python dict GameObject* createGameObject(id) { Gameobject* obj = new Gameobjec

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

2010-09-29 Thread Jim Bosch
of the raw Python C API to do it. It would certainly be harder than just adding str-like methods to a regular Boost.Python class. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] shared_ptr and register_ptr_to_python

2010-10-09 Thread Jim Bosch
ython the way described in the tutorial, and throw in some register_ptr_to_python invocations - that should be all you need. HTH! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] shared_ptr and register_ptr_to_python

2010-10-10 Thread Jim Bosch
On 10/10/2010 03:58 AM, Marek Denis wrote: On 10.10.2010 03:47, Jim Bosch wrote: Pretty much everything you need should automatically work, whether you use shared_ptr or raw pointers with call policies. If you've invoked register_ptr_to_python on all the classes you're using, Tha

Re: [C++-sig] shared_ptr and register_ptr_to_python

2010-10-10 Thread Jim Bosch
On 10/10/2010 02:16 PM, Marek Denis wrote: I did some tests to check it out (you can check the code at [1] ) and noticed, that when I launch the +v boost::python::call_method(callback,"addToQueue",c); -v piece of code, the object is copied after using self.queue.get() in the python script. This

Re: [C++-sig] shared_ptr and register_ptr_to_python

2010-10-11 Thread Jim Bosch
On 10/11/2010 10:49 AM, Marek Denis wrote: On 11.10.2010 00:42, Jim Bosch wrote: Essentially, what you need to do is pass a Python object to call_method (boost::python::object or PyObject *) that already contains your C++ object. In order to get one, you need need to tell Boost.Python to

Re: [C++-sig] Using C++ classes exposed by other modules

2010-10-14 Thread Jim Bosch
extra, and generally does in a lot of my own code. All I can think of is that your two modules somehow are getting different copies of the Boost.Python registry (maybe that happens with static linking to the Boost Python library - if that's even possible?)

Re: [C++-sig] Using C++ classes exposed by other modules

2010-10-19 Thread Jim Bosch
On 10/19/2010 05:10 AM, Nat Linden wrote: On Thu, Oct 14, 2010 at 1:17 PM, Bryant Gipson mailto:gipso...@yahoo.com>> wrote: C++: void mySlightlyHelpfulFunction(cppmodule::A &a) { ... } Python: a = mod.A() myModule.mySlightlyHelpfulFunction(a) myModul

Re: [C++-sig] Mapping RAW memory data into Python

2010-10-25 Thread Jim Bosch
it, you'll need to use Numpy. I've written a low-level Boost.Python interface to Numpy that you might find useful in that case here: http://svn.boost.org/svn/boost/sandbox/numpy/ ...but it will still be pretty complicated. Passing raw memory into Python is hard precisely because

Re: [C++-sig] Reference count on class object and import()

2010-11-02 Thread Jim Bosch
On 11/02/2010 11:04 AM, Simon W wrote: Alright, it was a couple of days ago since I last had a look on this and it turns out that issue described in my first mail still persists. Although I had a typo. Swap 4 with 3 on the reference count. Also, when Im using PyImport_Import() directly it also sh

Re: [C++-sig] Expose c++ class as python module

2010-11-09 Thread Jim Bosch
ar Boost.Python module. - In your module-that-mimics-a-class (pure Python), instantiate your instance in Python as a hidden module-level variable. - Extract bound methods from the instance and assign them to module-level variables. Jim Bosch __

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

2010-12-02 Thread Jim Bosch
owing and catching in a shared library that's linked to your Python module, and then try throwing and catching across the library boundary. You might also want to check the compile flags for Python itself, just in case there's something obviously different there between 64-bit and 32-

Re: [C++-sig] problems with typedef void *

2010-12-12 Thread Jim Bosch
ally considers everything an opaque pointer. If you don't have to use Boost.Python for other reasons, it might be worth a look, at least. Good luck! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

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

2011-01-03 Thread Jim Bosch
On 01/03/2011 01:44 PM, Ralf W. Grosse-Kunstleve wrote: - Original Message From: Neal Becker To: cplusplus-sig@python.org Sent: Mon, January 3, 2011 12:31:36 PM Subject: [C++-sig] Status of Numpy support in boost python - II I was just re-reading these posts: Status of Numpy support i

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

2011-01-04 Thread Jim Bosch
On 01/04/2011 05:34 AM, Neal Becker wrote: I'm interested in the ndarray http://code.google.com/p/ndarray package. I still need to figure out how to get it to compile against my customized boost installation in a non-standard location. Unfortunately, trying to build the 'test' results in ICE in

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

2011-01-04 Thread Jim Bosch
On 01/03/2011 04:46 PM, Stefan Seefeld wrote: On 01/03/2011 07:05 PM, Ralf W. Grosse-Kunstleve wrote: I think the low-level API I have in the sandbox fits this need, or at least provides some of the basics. I'd love to see that morph into something that we can all use to connect numpy to the C+

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

2011-01-07 Thread Jim Bosch
On 01/04/2011 11:35 AM, Jim Bosch wrote: On 01/04/2011 05:34 AM, Neal Becker wrote: I'm interested in the ndarray http://code.google.com/p/ndarray package. I still need to figure out how to get it to compile against my customized boost installation in a non-standard location. Unfortun

Re: [C++-sig] problem returning polymorphic shared_ptr instances

2011-01-12 Thread Jim Bosch
On 01/12/2011 09:03 AM, Matt Bendiksen wrote: I'm stumped on a problem encountered when trying to return a derived instance via a shared_ptr to python. The python instance is always shown as a base class and not the subclass that was created, as if the instance was sliced. struct A {

Re: [C++-sig] problem returning polymorphic shared_ptr instances

2011-01-12 Thread Jim Bosch
On 01/12/2011 12:06 PM, Matt Bendiksen wrote: Thanks Jim, but I still cannot get it to work. I now have it defined as: def("get_a_or_b_instance", get_a_or_b_instance); class_ >("A", init<>()) ; class_, bases >("B", init<>()) ; (note I change your example line from

Re: [C++-sig] GSoC 2011 proposal for improved NumPy wrapper ?

2011-03-23 Thread Jim Bosch
but I'd certainly like to help. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] GSoC 2011 proposal for improved NumPy wrapper ?

2011-03-24 Thread Jim Bosch
On 03/24/2011 06:31 AM, Neal Becker wrote: Jim Bosch wrote: On 03/23/2011 07:49 AM, Stefan Seefeld wrote: Hello, As you may have heard, Boost has once again been accepted as a mentoring organization in this year's Google Summer of Code program. One of the potential projects that we have

Re: [C++-sig] GSoC 2011 proposal for improved NumPy wrapper ?

2011-03-25 Thread Jim Bosch
On 03/25/2011 04:12 AM, Stefan Seefeld wrote: On 2011-03-25 06:55, Neal Becker wrote: John Reid wrote: Is support planned for boost::multi_arrays? If not, can I add my +1? John. If we're considering support for various c++ libs, ones to consider might include: eigen boost::multi_array boos

Re: [C++-sig] GSoC Boost.Python project

2011-03-30 Thread Jim Bosch
On 03/30/2011 08:01 PM, Ankit Daftery wrote: Hello I am working on the project proposal for GSoC 2011 for the Boost.python project, and I would like a little help. 1. ndarray.hpp mentions that functionality needs to be added like the one in boost::python::numeric::array . Stefan suggested that

Re: [C++-sig] transfer ownership problem

2011-05-04 Thread Jim Bosch
a little vague about the details - feel free to ask more questions if you need more help, but a look through the Boost.Python reference documentation for setting the "HeldType" of a class_ instantiation to a smart pointer should get you started. Good luck! Jim Bosch -- Vie

Re: [C++-sig] how to call base class method?

2011-05-06 Thread Jim Bosch
On 05/06/2011 06:51 PM, zeb wrote: I have 2 class exposed to python: class A { public: virtual int get() { return 1; } }; class B : public A { public: virtual int get() { return 2; } }; In python: obj = B() obj.get() # this will call B's get() For some reason, I want to call A's get(

Re: [C++-sig] boost::python - how to pass by reference/pointer to python overriden class functions

2011-05-25 Thread Jim Bosch
hich one is considered best (perhaps someone else on this list does?). But you might want to make sure this does what you expect. HTH Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Using boost::tuple from python

2011-06-25 Thread Jim Bosch
On 06/25/2011 11:40 AM, Jay Riley wrote: I figured I might be able to expose the tuple by some variation on the below: class_("ActionTargetTuple") .def("get", &ActionTargetTuple::get, return_value_policy()) ; then use get from python, but if it is doable in this way, I'm not sure what the set u

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-30 Thread Jim Bosch
d below with "ptr(keyboard)") on a noncopyable class. Are you hoping to support some specific one, or is this the root of your misunderstanding? Anyhow, I'd recommend trying class_("Keyboard", no_init); with the rest of what you have. Good luck

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-30 Thread Jim Bosch
On 07/30/2011 03:18 PM, Valentin Perrelle wrote: Thanks to you, I know understand some points i couldn't catch reading the manual 3-4 times. I'm now able to fix the current problem by importing my module before assigning the variable 'keyboard'. Which leads me to another question : is there a way

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-31 Thread Jim Bosch
On 07/31/2011 12:52 AM, Valentin Perrelle wrote: Le 31/07/2011 07:38, Jim Bosch a écrit : I guess I don't really understand how your program flow is supposed to work - how did you plan to invoke C++ code from Python before importing your Boost.Python module? Usually the natural pla

Re: [C++-sig] Boost.Python: Callbacks to class functions

2011-08-01 Thread Jim Bosch
l) - is pretty low level, and probably impossible with Boost.Python. Good luck! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Boost.Python: Callbacks to class functions

2011-08-01 Thread Jim Bosch
On 08/01/2011 09:44 PM, diego_pmc wrote: Are these cycles actually a problem in practice? Python does do garbage collection, so it might be that it knows about all these dependencies and just hasn't bothered to try to delete them because it doesn't need the memory yet. Y

Re: [C++-sig] extract<> with custom shared pointers

2011-08-05 Thread Jim Bosch
xtract_rvalue, or maybe arg_rvalue_from_python to get extraction working properly. I can provide more detail on how to do that if you need help, but everything I know I learned from reading the source. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus

Re: [C++-sig] How to import a boost::python dll in windows?

2011-08-05 Thread Jim Bosch
short on those. HTH Jim Bosch On 08/05/2011 01:43 PM, fjanoos wrote: Hi, I am having a similar problem as the o.p. I was trying to build Python wrappers for the hello_ext project given in the boost tutorial using CMake instead of bjam using the instructions as per http://mail.python.org/pipermai

Re: [C++-sig] Wrapping std::vector with boost::python::list

2011-08-09 Thread Jim Bosch
Just return boost::python::object by value; it's actually a smart pointer that carries a PyObject* and uses Python's reference counting, and you can implicitly create one from boost::python::list (since list derives from object). Just returning boost::python::list by value might also work, but

Re: [C++-sig] Functions exposed using boost::python not reported by the python profiler

2011-08-09 Thread Jim Bosch
On 08/09/2011 03:57 PM, Arnaud Espanel wrote: Hi -- When running a python program through the python profiler, calls to a function exposed directly through C python api are reported, but not the calls to a function exposed through boost::python. I'd like to see boost::python calls reported on the

Re: [C++-sig] arguments to c++ functions

2011-08-12 Thread Jim Bosch
bp::object const & o) { int n = bp::len(o); std::vector v(n); boost::scoped_array s(new char*[n]); for (int i = 0; i < n; ++i) { v[i] = bp::extract(o[i]); s[i] = v[i].c_str(); } original(s, n); } Good luck! Jim Bosch

Re: [C++-sig] automatic conversion from python unicode object to C++ std::string?

2011-08-12 Thread Jim Bosch
don't think the from-python conversions are terribly well-documented, but you can learn a lot from boost/python/converter/rvalue_from_python_data.hpp. If you need help, just ask. Good luck! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus

Re: [C++-sig] wrapped std::vector slice affecting items in a python list

2011-08-12 Thread Jim Bosch
his isn't a Boost.Python-specific problem, it's an inherent incompatibility between C++'s value-based containers and Python's shared-reference ones. Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] void* (void pointer) function arguments

2011-08-15 Thread Jim Bosch
could lead to big problems if you pass around things that aren't in fact PyObject* as void pointers in the same places, though I think your solution suffers from this too. There really isn't anything automatic for dealing with void pointers in Boost.Python, because it's so tem

Re: [C++-sig] wrapped std::vector slice affecting items in a python list

2011-08-16 Thread Jim Bosch
On 08/16/2011 07:32 AM, babak wrote: Hi Jim Thanks for your response. I'm abit surprised that this is the case, I kind of thought that indexing_suite was there to bridge this incompatibility. Is it normal then for large projects reliant on value based containers to copy data when going from pyt

Re: [C++-sig] wrapped std::vector slice affecting items in a python list

2011-08-16 Thread Jim Bosch
On 08/16/2011 11:29 AM, Babak Khataee wrote: Okay thanks for the info. Things are also a lot safer if you only wrap vectors as const; it's exposing the mutators to Python that gets really difficult. Is the const-ness of a wrapped object just a side effect of not exposing methods which

Re: [C++-sig] question about implicit type conversion of vector to a custom type

2011-08-16 Thread Jim Bosch
s by throwing an exception. The fix might be in how you've written your vector<> conversions; when given a list or tuple that contains the wrong element type, they need to report that they "don't match", rather than matching any list or tu

Re: [C++-sig] question about implicit type conversion of vector to a custom type

2011-08-18 Thread Jim Bosch
On 08/18/2011 09:37 AM, Grant Tang wrote: I change my vector<> conversion(see it in my last reply) to add specialization for int, float, string etc. I added type check in convertible() function: Sorry I didn't reply to your last email earlier, but it looks like you're on the right track. H

Re: [C++-sig] getting a list of strings from a static method

2011-08-25 Thread Jim Bosch
u can also do extract(), which may be more efficient if you have really large strings and don't want to copy them. Good Luck! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] Boost Python loss of values

2011-08-25 Thread Jim Bosch
this would cause the problem you're seeing (maybe you're slicing your AttackWrapper instances into Attack instances?) but I'd recommend fixing it first. Good Luck! Jim Bosch ___ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig

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

2011-08-25 Thread Jim Bosch
tached to people who are responsible for the excellent library we already have. - For other Boost.Python experts on this list: do you have existing code or development time you'd like to contribute? Thanks! Jim Bosch ___ Cplusplus-s

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

2011-08-26 Thread Jim Bosch
On 08/26/2011 04:17 AM, Neal Becker wrote: What sort of improvements did you have in mind? My list includes: - Propagating constness to Python (essentially already done as an extension, but it could have a much nicer interface if I could mess with class_ itself). - Make custom registry and

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

2011-08-26 Thread Jim Bosch
, but I guess I'm hoping for someone to tell me how it should fit; I don't want to presume that v3 is automatically a Boost library without permission, so it seemed safer to move it outside until it could officially win back its Boost status through review. Jim On Thu

  1   2   3   >