[C++-sig] exporting a boost::python::dict containing a boost::python::list

Niall Douglas s_sourceforge at nedprod.com
Sat Jul 21 11:40:59 CEST 2012


On windows, the only near equivalent to valgrind is Intel's suite of 
very expensive tools. If your company already has a licence, they are 
very good. If not, fire up a copy of Linux on your nearest VM node 
and port a small example of the problem in your BPL app over to GCC.

Niall


On 21 Jul 2012 at 11:25, Ronny Herzog wrote:

> Thanks for the answer, but I should add that I am using Windows 7 32Bit 
> with Python 2.6.
> 
> Ronny
> 
> Am 7/20/2012 5:19 PM, schrieb Ralf Grosse-Kunstleve:
> > without having looked at your code ...
> >
> > most likely this is a memory issue. run with valgrind (valgrind.org
> > <http://valgrind.org> or man valgrind) to pin-point the problem.
> >
> > On Fri, Jul 20, 2012 at 7:55 AM, Ronny Herzog <herzog at mpi-cbg.de
> > <mailto:herzog at mpi-cbg.de>> wrote:
> >
> >
> >     Dear all,
> >
> >     I want to export a boost::python::dict containing a
> >     boost::python::list. However, when I print this list in Python, I
> >     get an unlimited output of some strange numbers:
> >
> >     namespace bp = boost::python;
> >
> >     class readraw
> >     {
> >     ....
> >
> >                      bp::list mk_pyPeak_list()
> >                      {
> >                              bp::list py_peak_list;
> >                              for (int i = 0; i < peak_number; i++)
> >                              {
> >
> >     py_peak_list.append(bp::make___tuple(peak_list[0][i].mz,
> >     peak_list[0][i].intensity));
> >                              }
> >                              return py_peak_list;
> >                      }
> >
> >                      bp::dict peak_list_info()
> >                      {
> >                              bp::dict info;
> >                              //bp::object pn = peak_number;
> >                              //info["peakNumber"] = peak_number;
> >                              //std::cout <<
> >     bp::extract<int>(mk_pyPeak___list().attr("__len__")();
> >                              bp::list l(mk_pyPeak_list());
> >                              info["peakList"] = l;
> >
> >                              return info;
> >                      }
> >              };
> >
> >     BOOST_PYTHON_MODULE(readraw)
> >     {
> >              bp::class_<readraw>("readraw", bp::init<int>())
> >                      .def("add_peak", &readraw::add_peak)
> >                      .def("peak_list_info", &readraw::peak_list_info)
> >                      .def("average_scans", &readraw::average_scans)
> >                      ;
> >
> >     In Python:
> >      >>> print rawfilereader.peak_list_info()
> >
> >     Results in smth. like:
> >     ...
> >     (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925e+66),
> >     (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925e+66
> >     ), (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925e+66),
> >     (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925e+
> >     66), (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925e+66),
> >     (-431602080.0 <tel:%28-431602080.0>, -6.2774385622041925
> >     e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.2774385622041925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.27743856220419
> >     25e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.2774385622041925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.277438562204
> >     1925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.2774385622041925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.2774385622
> >     041925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.2774385622041925e+66), (-431602080.0 <tel:%28-431602080.0>,
> >     -6.27743856
> >     ...
> >
> >     What am I doing wrong?
> >
> >     Thanks for the help,
> >     Ronny
> >
> >     _________________________________________________
> >     Cplusplus-sig mailing list
> >     Cplusplus-sig at python.org <mailto:Cplusplus-sig at python.org>
> >     http://mail.python.org/__mailman/listinfo/cplusplus-sig
> >     <http://mail.python.org/mailman/listinfo/cplusplus-sig>
> >
> >
> >
> >
> > _______________________________________________
> > Cplusplus-sig mailing list
> > Cplusplus-sig at python.org
> > http://mail.python.org/mailman/listinfo/cplusplus-sig
> >
> 
> 
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig at python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig


-- 
Technology & Consulting Services - ned Productions Limited.
http://www.nedproductions.biz/. VAT reg: IE 9708311Q.
Work Portfolio: http://careers.stackoverflow.com/nialldouglas/


More information about the Cplusplus-sig mailing list