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

Re: [pygame] Python and Speed



On Thu, Apr 17, 2008 at 12:45 PM, Casey Duncan <casey@xxxxxxxxxxx> wrote:
Partitioned space is certainly a more complex algorithm, but so long as all of your "points" (spheres?)
Yes, one can think of one array as points and the other as spheres. 
are not close together, it is usually vastly more efficient. If the partition size is optimal, than the vast majority of particles will not be hitting the edge of a partition, that will be an edge-case (pun intended). Even for those that are it's usually still faster than the naive O(N^2) method that compares every point with every other.

This algorithm is only effective if the space is large relative to the collision geometries and they tend not to be clumped very close together.
In 3D space, there is a good deal of room, so I can see this being effective.  But again, this is only one example of countless slowdowns I've had.  Let's fix all of them in one fell swoop, no?  The program is slowing down because the computer is processing the program relatively inefficiently.  This is due to Python.  Programmers shouldn't have to optimize their inefficiently executed code, the code should just be executed efficiently.  
-Casey
Ian