[wxpython-users] Fast(er) pixel level access
Folkert Boonstra
F.Boonstra at inter.nl.net
Fri May 2 23:20:03 PDT 2008
Just an update on how far i got with getting it faster.
Replacing loops with list comprehensions is a major enhancement:
def applyRule(self, rule):
# Apply the rule
xdim = ydim = [d for d in range(DIM) if d>0 and d<(DIM-1)]
xydims = [(x,y) for x in xdim for y in ydim]
for xy in xydims:
r = rule(self.imgs['b'], xy[0], xy[1])
At first:
> --------------------------------------------------------------------------------
> Wed Apr 23 22:22:11 2008 caprofile7
>
> 1943247 function calls in 14.565 CPU seconds
> --------------------------------------------------------------------------------
>
Now:
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Sat May 3 08:15:09 2008 caprofile11
16257 function calls in 4.905 CPU seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 4.356 4.356 4.570 4.570
/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_core.py:7219(MainLoop)
15876 0.147 0.000 0.147 0.000
/home/folkert/workarea/cellularautomaton/dharana/wxCA/canumclass11.py:83(parity)
1 0.101 0.101 0.101 0.101
/home/folkert/workarea/cellularautomaton/dharana/wxCA/canumclass11.py:200(initBitmap)
4 0.079 0.020 0.079 0.020
/usr/lib/python2.5/site-packages/wx-2.8-gtk2-unicode/wx/_gdi.py:6105(GetFont)
1 0.062 0.062 0.209 0.209
/home/folkert/workarea/cellularautomaton/dharana/wxCA/canumclass11.py:322(applyRule)
--------------------------------------------------------------------------------
More information about the wxpython-users
mailing list