What is the best way ? (1task - some task)

i’m currently, rewriting my source code and i was wondering, what’s the best way to do some task ?

with some tasks ?

def move (self, task) :
    #move code
    return task.cont

def rotate_camera(self,task) :
   #rotate code
   return task.cont


Or, juste with one task and some functions.

def grouptask(self, task) :
   if move :
  if rotate :
  return task.cont

def move(self) :
   #code for moving

def rotate(self) :
  #code for rotate


what is the method that got the best perfomance ?
Its second for me but i’ll will to get other point of view.
Thanks ^^

excuse my english again.

I think the performance consideration is secondary. The first consideration is, which approach will make the most sense to you and be easiest to maintain?


I’ve got a single task that takes care of the Movement based on Velocity and rotation values. On a key press these values are changed and it seems to be working rather well.

For me the two are similar, that’s why i’m wondering about that…
Perfomances is really important for my game, because there are a lot of thing to display, to calcul and if i can gain some FPS by one of these methods, it’s really good for me.

I cant really tell you if what is faster.

However this is most probably more of a python problem.

I recommend you using the profiler to find out what is using a lot of time. I had some success using this approach: vrplumber.com/programming/runsnakerun/

You can also check for bottlenecks using the internal panda3d profiler (pstats).

also check this website for hints how to improve python speed:

I’d support the approach, easier to read, makes finding bottlenecks easier and use the way you like more. Generally i’d say using 1 task is faster… (less lookups, and jumps) but that change will be so minimal that adding (1+1) would compensate it.

If time is critical and you are short on it, consider rewriting the most time using code objects in C.

Ok, tanks you , i’ll look at it