[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [Pygame] How can I have an accurate timing when I am showing an image?




On May 24, 2008, at 12:08 AM, Brian Fisher wrote:
On Fri, May 23, 2008 at 9:15 PM, Noah Kantrowitz <kantrn@xxxxxxx> wrote:

Anywhere you need that kind of timing accuracy, python is probably not the right tool for the job. I would recommend using plain SDL in C, you will likely find it much more stable timing-wise.

You may be right that python is a poor tool in cases where you need timing accuracy for stuff where you execute a lot of python code, but I really doubt python would pose any limitation for just showing an image for a specific amount of time. Task switching, timer resolution and video refresh all represent larger chunks of time than python code execution, and also the approach to doing the timing matters a lot more than whether python is executing it or c is for most tasks.

Beware the cycle detector. It introduceth non-deterministic execution profiles.

With that disabled, and care taken to make sure nothing will be loaded off disk when you don't expect it (lazy module loading or activation for example), it should be okay, but with C you know exactly what code is running and when.

A note on the original code, you probably want to use pygame.time.get_ticks(), not time.time().

--Noah