On Wednesday 21 January 2009 14:57:59 Neal Becker wrote: > ublas::vector<T> func (numpy::array_from_py<T>::type const&) > > But not for a function that modifies it arg in-place (& instead of const&): > > void func (numpy::array_from_py<T>::type &) ^^^^ Use void func (numpy::array_from_py<T>::type )
Why does this work? It is a tradeoff I had to make; I chose to use python conventions rather than C++ conventions. Essentially, what is passed back to you is a reference to the numpy array. Any copies you make of it are actually copies of the reference, not of the actual array. This simplifies the code quite a bit while maintaining the reference semantics that python programmers use. See dump_vec in decco.cc (the example module) for an example. Regards, Ravi _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion