need 16 arguments to a function...
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats. A
anders langlands wrote:
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats.
FWIW, I have used hand-coded construction / conversion code to generate C++ containers ('Vector', here) from python lists, such as this: std::auto_ptr<Vector> construct_vector(bpl::list l) { long len = bpl::extract<long>(l.attr("__len__")()); std::auto_ptr<Vector> vector(new Vector(len)); for (long i = 0; i != len; ++i) vector->put(i, bpl::extract<double>(l[i])); return vector; } May be something similar would work for you, too ? HTH, Stefan -- ...ich hab' noch einen Koffer in Berlin...
Aha yes that's much better, thank you A On 11/25/06, Stefan Seefeld <seefeld@sympatico.ca> wrote:
anders langlands wrote:
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats.
FWIW, I have used hand-coded construction / conversion code to generate C++ containers ('Vector', here) from python lists, such as this:
std::auto_ptr<Vector> construct_vector(bpl::list l) { long len = bpl::extract<long>(l.attr("__len__")()); std::auto_ptr<Vector> vector(new Vector(len)); for (long i = 0; i != len; ++i) vector->put(i, bpl::extract<double>(l[i])); return vector; }
May be something similar would work for you, too ?
HTH, Stefan
--
...ich hab' noch einen Koffer in Berlin... _______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
Hmmm OK now I actually try and use it, it crashes. This is very strange. I'm using almost exactly the same code in another part of my module for getting values back from a list. The code looks like this: M44f m44f_new( list ls ) { size_t len = boost::python::extract<size_t>( ls.attr( "__len__" )() ); M44f m; cerr << "Length is " << len << endl; for ( int i=0; i < len; ++i ) { cerr << "getting item " << i << endl; boost::python::object x = ls[i]; boost::python::extract<float> ex( x ); if ( ex.check() ) { *(m[ i ]) = ex(); } } return m; } and the output and gdb backtrace looks like this: Length is 16 getting item 0 getting item 1 getting item 2 getting item 3 getting item 4 getting item 5 Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1210632528 (LWP 5042)] 0xb7cb33a5 in boost::python::incref<_object> (p=0x0) at /usr/include/boost/python/refcount.hpp:16 16 Py_INCREF(python::upcast<PyObject>(p)); Current language: auto; currently c++ (gdb) bt #0 0xb7cb33a5 in boost::python::incref<_object> (p=0x0) at /usr/include/boost/python/refcount.hpp:16 #1 0xb7ab1762 in object_base (this=0xbf82dfa8, rhs=@0xbf82e03c) at /usr/include/boost/python/object_core.hpp:419 #2 0xb7ab1794 in object (this=0xbf82dfa8) at /usr/include/boost/python/object_core.hpp:294 #3 0xb7ab7e73 in proxy (this=0xbf82dfa8, target=@0xbf82e03c, key=@0xbf82df08) at /usr/include/boost/python/proxy.hpp:58 #4 0xb7ab7ec2 in boost::python::api::object_operators<boost::python::api::object>::operator[] (this=0xbf82e03c, key=@0xbf82df08) at /usr/include/boost/python/object_items.hpp:36 #5 0xb7ab93d1 in boost::python::api::object_operators<boost::python::api::object>::operator[]<int> (this=0xbf82e03c, key=@0xbf82dfb4) at /usr/include/boost/python/object_items.hpp:61 #6 0xb7ac872a in PymathBinding::m44f_new (ls=@0xbf82e03c) at src/Pymath.cpp:89 #7 0xb7ae460c in boost::python::detail::invoke<boost::python::to_python_value<Imath::Matrix44<float> const&>, Imath::Matrix44<float> (*)(boost::python::list), boost::python::arg_from_python<boost::python::list> > (rc=@0xbf82e07e, f=@0x817f794, ac0=@0xbf82e070) at /usr/include/boost/python/detail/invoke.hpp:75 #8 0xb7ae49bf in boost::python::detail::caller_arity<1u>::impl<Imath::Matrix44<float> (*)(boost::python::list), boost::python::default_call_policies, boost::mpl::vector2<Imath::Matrix44<float>, boost::python::list>
::operator() ( ---Type <return> to continue, or q <return> to quit--- this=0x817f794, args_=0xb7d0180c) at /usr/include/boost/python/detail/caller.hpp:199 #9 0xb7ae4a1a in boost::python::objects::caller_py_function_impl<boost::python::detail::caller<Imath::Matrix44<float> (*)(boost::python::list), boost::python::default_call_policies, boost::mpl::vector2<Imath::Matrix44<float>, boost::python::list> > ::operator() (this=0x817f790, args=0xb7d0180c, kw=0x0) at /usr/include/boost/python/object/py_function.hpp:38 #10 0xb7bbc6d6 in boost::python::objects::function::call () from /usr/lib/libboost_python-gcc-mt-1_33_1.so.1.33.1 #11 0x0817f790 in ?? () #12 0xb7d0180c in ?? () #13 0x00000000 in ?? ()
I'm calling it like this in the python script: xform = newM44f( [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 7.367355, 1.000000, ] ) Any ideas what could be happening? A On 11/25/06, anders langlands <anderslanglands@gmail.com> wrote:
Aha yes that's much better, thank you
A
On 11/25/06, Stefan Seefeld <seefeld@sympatico.ca> wrote:
anders langlands wrote:
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats.
FWIW, I have used hand-coded construction / conversion code to generate C++ containers ('Vector', here) from python lists, such as this:
std::auto_ptr<Vector> construct_vector(bpl::list l) { long len = bpl::extract<long>(l.attr("__len__")()); std::auto_ptr<Vector> vector(new Vector(len)); for (long i = 0; i != len; ++i) vector->put(i, bpl::extract<double>(l[i])); return vector; }
May be something similar would work for you, too ?
HTH, Stefan
--
...ich hab' noch einen Koffer in Berlin... _______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
anders langlands wrote:
Hmmm OK now I actually try and use it, it crashes. This is very strange. I'm using almost exactly the same code in another part of my module for getting values back from a list.
No idea. Is this a multi-threaded program ? Do other parts access the 'ls' list at the same time ? In that case you ought to serialize access by means of the global interpreter lock (GIL). Otherwise I have no clue, sorry. Regards, Stefan -- ...ich hab' noch einen Koffer in Berlin...
Sorry, don't mind me. I was trying to write into the matrix object the wrong way and i guess it was corrupting the stack :) Thanks for your help stefan A On 11/25/06, Stefan Seefeld <seefeld@sympatico.ca> wrote:
anders langlands wrote:
Hmmm OK now I actually try and use it, it crashes. This is very strange. I'm using almost exactly the same code in another part of my module for getting values back from a list.
No idea. Is this a multi-threaded program ? Do other parts access the 'ls' list at the same time ? In that case you ought to serialize access by means of the global interpreter lock (GIL). Otherwise I have no clue, sorry.
Regards, Stefan
--
...ich hab' noch einen Koffer in Berlin... _______________________________________________ C++-sig mailing list C++-sig@python.org http://mail.python.org/mailman/listinfo/c++-sig
On 11/25/06, anders langlands <anderslanglands@gmail.com> wrote:
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats. Take a look on this mail. http://mail.python.org/pipermail/c++-sig/2002-June/001554.html
I think, you don't need to re-compile boost.python, but your projects. ( But of course I could be wrong ) -- Roman Yakovenko C++ Python language binding http://www.language-binding.net/
"anders langlands" <anderslanglands@gmail.com> writes:
Can I change the max arguments limit for methods without recompiling boost::python? I need an initializer for a 4x4 matrix, hence the need for 16 floats.
http://www.boost.org/libs/python/doc/v2/configuration.html should tell you what you need to know. -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (4)
-
anders langlands -
David Abrahams -
Roman Yakovenko -
Stefan Seefeld