Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Hugo Arts
On Mon, Aug 17, 2009 at 11:59 PM, Ian Mallett wrote: > On Mon, Aug 17, 2009 at 1:42 PM, Hugo Arts wrote: >> >> How about writing a fragment shader? > > Well, vertex shaders and fragment shaders go together.  Sometimes a geometry > shader can be added between them.  Together they're a "shader". >>

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Ian Mallett
On Mon, Aug 17, 2009 at 1:42 PM, Hugo Arts wrote: > How about writing a fragment shader? Well, vertex shaders and fragment shaders go together. Sometimes a geometry shader can be added between them. Together they're a "shader". > I don't know whether this would > work or what performance woul

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Hugo Arts
On Mon, Aug 17, 2009 at 8:47 PM, Ian Mallett wrote: > I just realized, solution two might actually be better.  It will start out > much faster, and it's speed will converge to the speed of solution 1 as the > number of particles increases.  If you really wanted to get fussy, particles > that have h

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Ian Mallett
On Mon, Aug 17, 2009 at 11:34 AM, Hugo Arts wrote: > This is definitely true, however if you keep the amount of snow > particles constant but increase the resolution > you will see big performance hits. There is a classic performance > trade-off, with solution number 1 being independent of the sc

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Hugo Arts
On Mon, Aug 17, 2009 at 6:32 PM, Ian Mallett wrote: > What I like about the OP's approach, and about the numpy version of it, is > that it's perfectly scalable to any number of particles.  The program as I > modified it runs ~30 fps--but it runs about 30fps whether you add random > particles 8 or 1

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Ian Mallett
On Mon, Aug 17, 2009 at 2:50 AM, Hugo Arts wrote: > My gut says this is most definitely the fastest way to go for small > numbers of snow flakes. > I suspect there is a certain point at which the numpy approach by Ian > wins out (especially if you can > optimize that a little more like Ian sugges

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Hugo Arts
My gut says this is most definitely the fastest way to go for small numbers of snow flakes. I suspect there is a certain point at which the numpy approach by Ian wins out (especially if you can optimize that a little more like Ian suggests, though I don't know enough about numpy). Some good tips t

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread don
Hi Note that didn't run any tests/profiling (no pygame installed on this machine). Anyway, here are my suggestions: 1) in "init()" instead of setting pixel per pixel to green use "pygame.draw.line()" 2) in "snowfall()" you check every pixel on every frame. this is most likly your bottleneck.

Re: [pygame] is there a way to optimize this code?

2009-08-17 Thread Ian Mallett
Cool effect! Well, short of doing anything drastic--like using the GPU to simulate it, let's try some things, in the order I thought of them. First, to establish a baseline, I added a framerate counter and got just over 6 fps. -Adding import psyco psyco.full() increased 1 fps -By far the slowes

[pygame] is there a way to optimize this code?

2009-08-16 Thread Victor Noagbodji
hi, i'm following SDL tutorial here, http://sol.gfxile.net/gp/ch04.html this is the pygame equivalent. as you can see the code is not nice looking. that's because i have tried all the optimization tricks i know (local names, avoid dot operators, numpy array etc...) the result is still awfully slow