On Wed, Apr 28, 2010 at 11:24 PM, Florian Bösch <[email protected]> wrote: > On Apr 29, 4:04 am, Joe Wreschnig <[email protected]> wrote: >> This is an optimization for VertexBufferObjectRegion.invalidate. I'm >> not sure what to say about it. It's trivial and much >> faster.http://code.google.com/p/pyglet/issues/detail?id=480 > How much faster is that?
As the commit message says, about 3x faster, and invalidate is in turn a large part of the cost of updating a sprite's vertices. Python max and min are ridiculously slow because of how much work they do. A quick timeit bears out the 3x claim: $ python -m timeit "a = 1; b = 2; c = max(a, b)" 1000000 loops, best of 3: 0.438 usec per loop $ python -m timeit "a = 1; b = 2; c = a if a > b else b" 10000000 loops, best of 3: 0.153 usec per loop >> This adds independent x and y scaling to sprites. There are two bugs >> in the first patch which are fixed in the second and >> third.http://code.google.com/p/pyglet/issues/detail?id=481 > I like it if I can write: > > somesprite.scale = 2.0, 0.5 > > instead of: > > somesprite.scale_x = 2.0 > somesprite.scale_y = 0.5 I like this, but I'm not sure how it could be implemented efficiently. If you use try/except, setting the scale becomes much more expensive than it is now. If you use isinstance, it's not as bad, but you have to hope no one passes in a strange sequence type. -- 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.
