On Thu, Apr 29, 2010 at 3:50 AM, Joe Wreschnig <[email protected]>wrote:
> 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 > > what about: >>> s3 = """\ ... a=1; b=2 ... if a>b: ... c=a ... else: ... c=b ... if a<b: ... d=b ... else: ... d=a ... """ >>> t = timeit.Timer(stmt=s3) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 0.25 usec/pass >>> s2 = a=1; b=2 >>> s2 = """\ ... a=1; b=2 ... c = a if a>b else b ... d = b if a<b else a ... """ >>> t = timeit.Timer(stmt=s2) >>> print "%.2f usec/pass" % (1000000 * t.timeit(number=100000)/100000) 0.26 usec/pass The timings are near, but the first doesn't break compat with 2.4 I dont use so much 2.4, except when there are no binaries for 2.6, like that physics lib (pyOde ? pyOgre?) It is not so much important for me, but perhaps is better if you state what python version will support pyglet. -- claudio -- 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.
