<div class="gmail_quote">On Wed, Aug 26, 2009 at 2:40 PM, Simon Wittber <span dir="ltr">&lt;<a href="mailto:simonwittber@gmail.com">simonwittber@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Aug 26, 2009 at 5:31 PM, Dan Sanduleac&lt;<a href="mailto:sanduleac.dan@gmail.com">sanduleac.dan@gmail.com</a>&gt; wrote:<br>
&gt; The testing goes like this: each &quot;tick&quot;, 10000 objects update their<br>
&gt; position, according to their velocity and timedelta since last &quot;tick&quot;, and<br>
&gt; I&#39;m measuring the average time a tick takes to complete.<br>
<br>
</div>I know that I&#39;m not answering your question, but I thought I might<br>
throw in some advice, if you have a need for speed.<br>
<br>
It would be much faster to create an Vec3Array type object, and do the<br>
loop iteration with the += operating inside C++. This would make your<br>
Python API look something like:<br>
<br>
positions = Vec3Array(10000)<br>
velocities = Vec3Array(10000)<br>
positions += velocities<br>
<br>
Also, Stackless will have little effect your benchmarks, so you may<br>
find more answers in a more general forum.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
    :: Simon Wittber<br>
    :: <a href="http://www.linkedin.com/in/simonwittber" target="_blank">http://www.linkedin.com/in/simonwittber</a><br>
    :: phone: +61.4.0135.0685<br>
    :: jabber/msn: <a href="mailto:simonwittber@gmail.com">simonwittber@gmail.com</a></font></blockquote><div><br>Thanks for the reply :D<br>I know, I posted on the c++-sig list first, but didn&#39;t get an answer there so I decided to post on stackless too. <br>
<br>What you&#39;re suggesting would of course speed up the process dramatically, but each of those objects lives in its own tasklet, and I wanted to simulate 10000 objects each performing some action (per game tick), say updating its position, in its &quot;run-loop&quot;. Because of this, I couldn&#39;t code the loop in C, as I&#39;m stuck with the one from stackless&#39; scheduler.<br>
<br>Of course, in a real game, the position wouldn&#39;t be updated by each object in its own thread. There would be a second stage in which a faster (compiled) physics engine would do this. However, this was just for testing and I couldn&#39;t think of something else.<br>
<br>OvermindDL1 solved my problem, letting me know that I was dealing with heavy function call overhead, which added up because I was calling C functions from python at a very fast rate.<br></div></div><br>