[C++-sig] Question: compiling library using <python/numeric.cpp>

Philip Austin paustin at eos.ubc.ca
Thu Jun 24 18:53:36 CEST 2004


Peter Vandersteegen writes:
 > Hello,
 > 
 > Therefor I've one question:

[snip]

 > 
 > * The project num_util 
 > (http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/) uses 
 > the fist method?  They use boost as wrapper, but for the array class, they 
 > directly use the python numeric array class and not the boost.python array 
 > class?
 > * Directly using <python/Numeric.hpp> seperates you from dealing with the 
 > 'raw' python numeric array class?  Added bonus: no need to write 
 > import_array() in BOOST_PYTHON_MODULE...

That's right  -- also, by using callbacks into python, David was able
to make the same implementation work for both Numeric and Numarray
(the successor to Numeric, which is not completely backward
compatible).  We use num_util because (in decreasing order of importance):
i) we need to move large arrays between python and C++, which means
we need access to the PyArrayObject pointer.  Numeric.hpp only
supports copying your results into a new tuple or list to return
to python.  ii) the callback overhead can be substantial for some
of our applications.  iii) we have a quite a bit of legacy code developed
for our interface under boost v1, which predates Numeric.hpp.

Regards, Phil








More information about the Cplusplus-sig mailing list