Hi Stefan,<br>
<br>
Thanks very much.<br>
<br>
&gt; make that<br>
&gt;float f = boost::python::extract&lt;float&gt;(rlt);<br>&gt;Would that work ?<br clear="all">It works if arg_op = plus or minus. ( here process(boost::python::object arg_op)).<br>
But it didn't work if arg_op = vectorPlus. It seems that arg_op can't accept a c++ float pointer.<br>
<br>
Acctually the real vectorPlus() used in my code has been optimized for
speed and kindof unfriendly readable. I listed the simple version of
vectorPlus() which had the same idea and problem. For speed reason, I
can't use plus(p1[i],p2[i]) instead of vectorPlus(p1,p2,length).So I
hope vectorPlus can work.<br>
<br>
---------------------c extension-----------------<br>
vectorPlus(float* p1, float* p2,int point_len)// plus for two vectors.<br>
{<br>
&nbsp;&nbsp; float sum = 0;<br>
&nbsp;&nbsp; for (int i=0;i&lt;point_len;i++)<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sum += *(p1+i) + *(p2+i);<br>
&nbsp;&nbsp; } <br>
&nbsp;&nbsp; return (sum);<br>
}<br>
<br>
boost::python::object op;<br>
<br>
void process(boost::python::object arg_op){<br>
 &nbsp; ...<br>
 &nbsp; op = arg_op;<br>
 &nbsp; ...<br>
 &nbsp; float * a = {1,2};<br>
 &nbsp; float * b = {3,4};<br>
<br>
 &nbsp; boost::python::object rlt = op(a,b,2); // can't accept float* parameters.<br>
 &nbsp; float * f = boost::python::extract&lt;float&gt; (rlt);<br>
 &nbsp; printf(&quot;%f \n&quot;,*f);<br>
 &nbsp; ...<br>
}<br>
----------------------result --------------------<br>
&gt;&gt;&gt; import hello<br>
&gt;&gt;&gt; hello.process(hello.vectorPlus)<br>
Traceback (most recent call last):<br>
&nbsp; File &quot;&lt;stdin&gt;&quot;, line 1, in ?<br>
TypeError: No to_python (by-value) converter found for C++ type: float*<br>
&gt;&gt;&gt;<br>
<br>
<br>-- <br>Qinfeng(Javen) Shi <br><br>Research School of Information Sciences and Engineering<br>Australian National University<br>Locked Bag 8001<br>Canberra ACT 2601<br><br><br>