Speedup Bitmap Parser

Tim Wintle tim.wintle at teamrubber.com
Tue Feb 17 04:05:49 EST 2009


On Mon, 2009-02-16 at 16:47 -0800, bearophileHUGS at lycos.com wrote:
> Jayson Santos:
> > Do I need use some patters or others progamming conventions ?
> 
> That's a strong question...
> Knowing OOP well is important, and it's often a good way to program,
> etc. But... You may try to rewrite your code with functions only and
> no classes (well, you may need to use classes for the TK gui).
> Feel free to not follow this suggestion of mine. Even if you follow
> it, it will not damage your brain :-)

I'd strongly agree with the above - object creation is overkill in
inner-loops.

Invoking functions and any kind of variable allocation is also going to
slow it down. That's what bearophile's previous comment about accessing
line.colors without the "." lookup by enumerating them was about.

At the end of the day, image manipulation is often better left to C (or
compiled extensions to python in Cython etc.) than done in Python - it's
just too tough to do pointer-magic in Python. You may find that so much
time is being spent by your application in the ".create_line" method
that there's no other option - I'd highly recommend PIL though.


Tim Wintle




More information about the Python-list mailing list