Searching a fastest code


I made a simple speed test .blend file to test & find a best way to design & optimize my code.

So far IPO is the fastest method, but unfortunately I can’t use it in this way in run-time/.exe


Calculating the CL values with 0.0001 degrees AOA step. 1800000 calculations

Move cursor to on 3D view.
Start the test by hiting the P-key.
wait until the ‘’ shows the result.

Test PC
Operating System: Windows XP Home Edition SP3
Processor: Intel® Core™2 Quad CPU Q9300 @ 2.50GHz (4 CPUs)
Memory: 3328MB RAM
Page File: 586MB used, 4624MB available

script time(sec float)

C1 ~6.5
C2 ~3.0 # IPO-bezier
C2 ~2.8 # IPO-linear



Speed_test011.blend (121 KB)

For computationally heavy operations you might consider developing a C library with a python interface, you can make it portable enough to run in all platforms blender runs on and include it with your packaged game. Just an idea…

How did you get the time each script took to run? Using the python time module? Is that an efficient way to benchmark code? I would like to test which parts of my code is heavier but I’m not sure what’s the best way to procede :S

What is the problem with IPO?

Because this code only works in .blend but not in runtime .exe.

from Blender import Ipo # this don't work

import GameLogic as g
obj = g.getCurrentController().owner

if hasattr (obj, 'int') == False:
    ipo = Ipo.Get('ObIpo') = ipo[Ipo.OB_ROTX]

i_x = 10.0

i_y =[i_x]

Ah, I see. Yes, the module Blender is not available in runtime.

For what do you need that 1800000 pre-calculated data elements?
Maybe it is better to explain what you want to achive. There are usually multiple solutions.

Those 1800000 calculations are only for the function timing tests.

I’m looking a fast python method for the linear interpolation with given afp-data function of aoa (-+90degree).

OK. I have to say, I do not know what afp and aoa is, so I can’t help with this.

Linear interpolation itself should be cheap. It might be ok to calculate the actual value when it is needed.