Speedup Bitmap Parser

Jayson Santos santosdosreis at gmail.com
Mon Feb 16 19:13:13 EST 2009


On 16 fev, 20:41, bearophileH... at lycos.com wrote:
> Jayson Santos:
>
> > Here is the new code using your changeshttp://pastebin.com/m6dfe619d
> > And here is the profilerhttp://pastebin.com/m74d282b8
>
> I have suggested you to profile the program mostly for pedagogical
> purposes, it's often a good thing to do if you want to speed up a
> program. But now it's your job to read the output of the profiler and
> try to find where the performance problems are. The profiler output
> will be simpler for you to read if you sort lines according to
> something better than method name (something like the time used by
> functions sounds better) and you tell the profiler to show only the
> first few lines.
>
> But a profiler isn't enough, you also need to use the brain. Your code
> looks a bit too much OOP :-) So in Java your code may run fast enough,
> but in Python it may be too much slow.
> The suggestions by Terry are good if you want to speed up your code
> signifiantly. Creating a very large amount of objects inside inner
> loops a slow thing in Java too, not just in Python. Generally to
> create an object you need to allocate memory. Try to write your program
> (s) avoiding all or most memory allocations inside the inner loops,
> and you will see a big improvement in running speed.
>
> Bye,
> bearophile

Hello bearophile,
Thank you for all, I'm reviewing all my code.
Do I need use some patters or others progamming conventions ?
I tried PIL and PyGame source however they are in C and I can't
understand read and draw functions.
Do you know a python-only image library ?

Best Regards
Jayson



More information about the Python-list mailing list