My suggestion: Do the simplest thing you can think of, if that isn't
fast enough then fix it. Have you proven that simply looping through
the objects and updating them is too slow?

If so there are few options within python itself to "mass update"
things. The usual suspects are generally employed: numpy or native
code. Richard's suggestion of rabbyt is also a good one since it is
specifically designed for this task.

-Casey

On Wed, Jul 15, 2009 at 12:44 PM, rollbak<[email protected]> wrote:
>
> Sorry forgot the sequence...
>
>  you can re-write it like this:
>  eg: map(lambda s: s.update(dx,dy), sprites)
>
>
> On Jul 15, 3:43 pm, rollbak <[email protected]> wrote:
>> I think the fastest approach using just python is to use map built-in
>> function.
>>
>> If you have the following loop:
>> eg: for s in sprites:
>>        s.update(dx,dy)
>>
>> you can re-write it like this:
>> eg: map(lambda s: s.update(dx,dy))
>>
>> regards,
>>
>> Lucas
>>
>> On Jul 14, 12:05 pm, Eric Burgess <[email protected]> wrote:
>>
>> > Pyglet provides some great ways to reduce function-call overhead for
>> > sprites (groups and batches).  But I still find myself looping through
>> > X sprites Y times a second, where X*Y can get quite large, doing
>> > things like "x+=dx;y+=dy".  I know there are packages like SciPy that
>> > can add an entire "dx" array to an "x" array at C-speed, but I'd
>> > rather not add the dependency.
>>
>> > Is there a "best practice" for doing this sort of thing in pure Python?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to