Help: Quick way to test if value lies within a list of lists of ranges?

Jean-Paul Calderone exarkun at divmod.com
Thu Oct 27 11:07:03 EDT 2005


On Thu, 27 Oct 2005 15:48:53 +0100 (BST), Ben O'Steen <bosteen at maysubdivide.org> wrote:
>Scenario:
>=========
>
>Using PyGame in particular, I am trying to write an application that will
>run a scripted timeline of events, eg at 5.5 seconds, play xxx.mp3 and put
>the image of a ball on screen, at 7.8 seconds move the ball up and down.
>At this point, I hear you say 'Oh, like Flash'.
>
> [snip - how do I make it go fast?]

I'm sure you'll get a lot of suggestions for fast algorithms
to solve this problem, but before you do, let me suggest that
this is actually a premature optimization.

I bet there are much more interesting problems to be solved in
this project, ones that you could work on and test, even while
doing something as unbelievable slow as looping over 100 or so
objects. ;)

You can always optimize later, after you've identified that this
operation is actually a bottleneck.

Jean-Paul



More information about the Python-list mailing list