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

Re: [pygame] Flood Fill



One other question. Why is numarray faster?
It would seem that line 2 and 3 are setting up a surface.get_at in the
background.
Also why don't you lock the surface for the surfarray? I know it does
it by itself but then so does surface.get_at. It would look to me like
these both would run at the same speed. Why is numarray faster?

Also note the error correction in line 11.

01   try:
02       surfaceA=pygame.surfarray.pixels2d(surface)
03       patternA=pygame.surfarray.pixels2d(pattern)
04       old_color = surfaceA[x][y]
05       new_color = patternA[x%pat_width][y%pat_height]
06       usearray=True
07   except:
08       surface.lock()
09       pattern.lock()
10       old_color = surface.get_at((x,y))
11       new_color = pattern.get_at((x%pat_width, y%pat_height))
12       usearray=False

On 11/30/05, Peter Shinners <pete@xxxxxxxxxxxx> wrote:
> On Wed, 2005-11-30 at 14:16 +0100, Bo Jangeborg wrote:
> > Talking about numeric, are there any plans to replace it with scipy ?
>
> Do you mean replacing Numeric with the newer numarray? It is an overdue
> change. Originally the two array libraries were a bit different, but
> these days they are compatable.
>
> The thing I didn't like about numarray is that it is actually slower for
> "smaller" sized arrays. Many game sprite images would fit into this
> smaller category. It's been way too long since I looked into this
> though.
>
>
>
>